diff --git a/cmdline/main.c b/cmdline/main.c index 8d2a8a9e..2c61811e 100644 --- a/cmdline/main.c +++ b/cmdline/main.c @@ -65,7 +65,6 @@ static uintptr_t receive_event(mrmailbox_t* mailbox, int event, uintptr_t data1, { case MR_EVENT_GET_STRING: case MR_EVENT_GET_QUANTITY_STRING: - case MR_EVENT_WAKE_LOCK: break; /* do not show the event as this would fill the screen */ case MR_EVENT_INFO: diff --git a/src/mrevent.h b/src/mrevent.h index 204ecf5e..7ef431cd 100644 --- a/src/mrevent.h +++ b/src/mrevent.h @@ -322,21 +322,6 @@ extern "C" { */ #define MR_EVENT_HTTP_GET 2100 -/** - * Acquire or release a wakelock. - * - * The core surrounds critical functions that should not be killed by the operating system with wakelocks. - * Before a critical function _MR_EVENT_WAKE_LOCK with data1=1_ is called, when it finishes, _MR_EVENT_WAKE_LOCK with data1=0_ is called. - * If you do not need this functionality, just ignore this event. - * - * @param data1 1=acquire wakelock, 0=release wakelock, the core does not make nested or unsynchronized calls - * - * @param data2 0 - * - * @return 0 - */ -#define MR_EVENT_WAKE_LOCK 2110 - #ifdef __cplusplus } /* /extern "C" */ diff --git a/src/mrimap.c b/src/mrimap.c index ff090cc1..866b0cb9 100644 --- a/src/mrimap.c +++ b/src/mrimap.c @@ -30,8 +30,8 @@ #include "mrosnative.h" #include "mrloginparam.h" -#define LOCK_HANDLE pthread_mutex_lock(&ths->m_hEtpanmutex); mrmailbox_wake_lock(ths->m_mailbox); handle_locked = 1; -#define UNLOCK_HANDLE if( handle_locked ) { mrmailbox_wake_unlock(ths->m_mailbox); pthread_mutex_unlock(&ths->m_hEtpanmutex); handle_locked = 0; } +#define LOCK_HANDLE pthread_mutex_lock(&ths->m_hEtpanmutex); handle_locked = 1; +#define UNLOCK_HANDLE if( handle_locked ) { pthread_mutex_unlock(&ths->m_hEtpanmutex); handle_locked = 0; } #define BLOCK_IDLE pthread_mutex_lock(&ths->m_idlemutex); idle_blocked = 1; #define UNBLOCK_IDLE if( idle_blocked ) { pthread_mutex_unlock(&ths->m_idlemutex); idle_blocked = 0; } diff --git a/src/mrmailbox-private.h b/src/mrmailbox-private.h index d6f99d06..debde0d4 100644 --- a/src/mrmailbox-private.h +++ b/src/mrmailbox-private.h @@ -63,9 +63,6 @@ struct _mrmailbox uint32_t m_cmdline_sel_chat_id; /**< Internal */ - int m_wake_lock; /**< Internal */ - pthread_mutex_t m_wake_lock_critical; /**< Internal */ - int m_e2ee_enabled; /**< Internal */ #define MR_LOG_RINGBUF_SIZE 200 @@ -91,8 +88,6 @@ void mrmailbox_receive_imf (mrmailbox_t*, uint32_t mrmailbox_send_msg_object (mrmailbox_t*, uint32_t chat_id, mrmsg_t*); void mrmailbox_ll_connect_to_imap (mrmailbox_t*, mrjob_t*); void mrmailbox_ll_disconnect (mrmailbox_t*, mrjob_t*); -void mrmailbox_wake_lock (mrmailbox_t*); -void mrmailbox_wake_unlock (mrmailbox_t*); int mrmailbox_get_archived_count__ (mrmailbox_t*); size_t mrmailbox_get_real_contact_cnt__ (mrmailbox_t*); uint32_t mrmailbox_add_or_lookup_contact__ (mrmailbox_t*, const char* display_name /*can be NULL*/, const char* addr_spec, int origin, int* sth_modified); diff --git a/src/mrmailbox.c b/src/mrmailbox.c index 2ae88cfb..3685cd0e 100644 --- a/src/mrmailbox.c +++ b/src/mrmailbox.c @@ -108,8 +108,6 @@ mrmailbox_t* mrmailbox_new(mrmailboxcb_t cb, void* userdata, const char* os_name pthread_mutex_init(&ths->m_log_ringbuf_critical, NULL); - pthread_mutex_init(&ths->m_wake_lock_critical, NULL); - ths->m_magic = MR_MAILBOX_MAGIC; ths->m_sql = mrsqlite3_new(ths); ths->m_cb = cb? cb : cb_dummy; @@ -173,7 +171,6 @@ void mrmailbox_unref(mrmailbox_t* mailbox) mrimap_unref(mailbox->m_imap); mrsmtp_unref(mailbox->m_smtp); mrsqlite3_unref(mailbox->m_sql); - pthread_mutex_destroy(&mailbox->m_wake_lock_critical); pthread_mutex_destroy(&mailbox->m_log_ringbuf_critical); for( int i = 0; i < MR_LOG_RINGBUF_SIZE; i++ ) { @@ -359,37 +356,6 @@ char* mrmailbox_get_blobdir(mrmailbox_t* mailbox) } -void mrmailbox_wake_lock(mrmailbox_t* mailbox) -{ - if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { - return; - } - pthread_mutex_lock(&mailbox->m_wake_lock_critical); - mailbox->m_wake_lock++; - if( mailbox->m_wake_lock == 1 ) { - mailbox->m_cb(mailbox, MR_EVENT_WAKE_LOCK, 1, 0); - } - pthread_mutex_unlock(&mailbox->m_wake_lock_critical); -} - - -void mrmailbox_wake_unlock(mrmailbox_t* mailbox) -{ - if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { - return; - } - pthread_mutex_lock(&mailbox->m_wake_lock_critical); - if( mailbox->m_wake_lock == 1 ) { - mailbox->m_cb(mailbox, MR_EVENT_WAKE_LOCK, 0, 0); - } - - if( mailbox->m_wake_lock > 0 ) { - mailbox->m_wake_lock--; - } - pthread_mutex_unlock(&mailbox->m_wake_lock_critical); -} - - /******************************************************************************* * INI-handling, Information ******************************************************************************/ diff --git a/src/mrsqlite3.c b/src/mrsqlite3.c index 1f07741f..5f49af93 100644 --- a/src/mrsqlite3.c +++ b/src/mrsqlite3.c @@ -695,8 +695,6 @@ void mrsqlite3_lock(mrsqlite3_t* ths) /* wait and lock */ #ifdef MR_USE_LOCK_DEBUG mrmailbox_log_info(ths->m_mailbox, 0, "{{{ LOCK AT %s#L%i after %.3f ms", filename, linenum, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC); #endif - - //mrmailbox_wake_lock(ths->m_mailbox); } @@ -706,8 +704,6 @@ void mrsqlite3_unlockNdebug(mrsqlite3_t* ths, const char* filename, int linenum) void mrsqlite3_unlock(mrsqlite3_t* ths) #endif { - //mrmailbox_wake_unlock(ths->m_mailbox); - #ifdef MR_USE_LOCK_DEBUG mrmailbox_log_info(ths->m_mailbox, 0, " UNLOCK AT %s#L%i }}}", filename, linenum); #endif