#include <stdio.h>
#include <glib.h>
#include "contentListerLog.h"
#include "pincodeIdleTime.h"
Go to the source code of this file.
Functions | |
static void | accumulate_idle_time_set (gint value) |
void | accumulate_idle_time_begin () |
void | accumulate_idle_time_end () |
void | accumulate_idle_time_set_threshold (gint threshold) |
void | accumulate_idle_time_set_callback (on_threshold_t *func) |
void | accumulate_idle_time_reset () |
gint | accumulate_idle_time_get () |
Variables | |
static accumulateIdleTime_t * | g_accumulate_idle_time = NULL |
accumulate time of being idle, when being idle for a long time, reach the threshold, call callback function of "accumulateIdleTime_t" to do something special, then end the accumulate idle time
if no threshold(default), just accumulating idle time, don't call callback function
in some case, e.g connectMgr and downloadMgr, if user sets threshold to be 5 mins, but downloading process needs more time which can not be forecasted, in this case, we need no threshold temporily
in pincode's case, "accumulatedIdleTime_t" is based on window application. when create widget, begin to accumulate idle time at the same time. when received key or button event, reset 'accumulate idle time' to zero
Copyright (C) 2006-2008 iRex Technologies BV. All rights reserved.
Definition in file pincodeIdleTime.c.
void accumulate_idle_time_begin | ( | ) |
begin to accumulate idle time
- |
Definition at line 53 of file pincodeIdleTime.c.
00054 { 00055 CL_LOGPRINTF("ACCUMULATE_IDLE_TIME_BEGIN"); 00056 accumulateIdleTime_t *idle_time = NULL; 00057 00058 if (NULL != g_accumulate_idle_time) 00059 { 00060 accumulate_idle_time_end(); 00061 } 00062 00063 idle_time = g_new0(accumulateIdleTime_t, 1); 00064 g_return_if_fail(NULL != idle_time); 00065 00066 // set the default value 00067 idle_time->milliseconds = 0; 00068 idle_time->threshold = 0; // default no threshold 00069 idle_time->callback_on_threshold = NULL; 00070 idle_time->internal = TIMEOUT_INTERNAL; 00071 // idle_time->timeout_handler_id = g_timeout_add( idle_time->internal, 00072 // accumulate_idle_time_increase, 00073 // (gpointer) idle_time->internal ); 00074 00075 g_accumulate_idle_time = idle_time; 00076 }
void accumulate_idle_time_end | ( | ) |
stop accumulating idle time
- |
Definition at line 78 of file pincodeIdleTime.c.
00079 { 00080 CL_LOGPRINTF("ACCUMULATE_IDLE_TIME_END"); 00081 00082 if (g_accumulate_idle_time) 00083 { 00084 if (g_accumulate_idle_time->timeout_handler_id) 00085 { 00086 g_source_remove(g_accumulate_idle_time->timeout_handler_id); 00087 } 00088 g_free(g_accumulate_idle_time); 00089 g_accumulate_idle_time = NULL; 00090 } 00091 }
gint accumulate_idle_time_get | ( | ) |
get the milliseconds for being idle
- |
Definition at line 165 of file pincodeIdleTime.c.
00166 { 00167 gint ms = 0; 00168 accumulateIdleTime_t *idle_time = g_accumulate_idle_time; 00169 00170 if (idle_time) 00171 { 00172 ms = idle_time->milliseconds; 00173 } 00174 return ms; 00175 }
void accumulate_idle_time_reset | ( | ) |
reset 'accumulate idle time' to zero
- |
Definition at line 117 of file pincodeIdleTime.c.
00118 { 00119 CL_LOGPRINTF("ACCUMULATE_IDLE_TIME_SET"); 00120 00121 accumulate_idle_time_set(0); 00122 }
static void accumulate_idle_time_set | ( | gint | value | ) | [static] |
Definition at line 155 of file pincodeIdleTime.c.
00156 { 00157 accumulateIdleTime_t *idle_time = g_accumulate_idle_time; 00158 00159 if (idle_time) 00160 { 00161 idle_time->milliseconds = value; 00162 } 00163 }
void accumulate_idle_time_set_callback | ( | on_threshold_t * | func | ) |
set callback function on threshold of 'accumulateIdleTime_t" when idle time reachs the threshold, call it to do something sepcial
- | func callback function address |
Definition at line 106 of file pincodeIdleTime.c.
00107 { 00108 accumulateIdleTime_t *idle_time = g_accumulate_idle_time; 00109 00110 if (idle_time) 00111 { 00112 idle_time->callback_on_threshold = func; 00113 } 00114 }
void accumulate_idle_time_set_threshold | ( | gint | threshold | ) |
set threshold of 'accumulateIdleTime_t'
- | threshold- after being idle for 'threshold' milliseconds, call callback function on threshold if threshold set zero, that means no threshold |
Definition at line 95 of file pincodeIdleTime.c.
00096 { 00097 accumulateIdleTime_t *idle_time = g_accumulate_idle_time; 00098 00099 if (idle_time) 00100 { 00101 idle_time->threshold = threshold; 00102 } 00103 }
accumulateIdleTime_t* g_accumulate_idle_time = NULL [static] |
Definition at line 47 of file pincodeIdleTime.c.