#include <glib.h>
#include "commonData.h"
#include "pingThread.h"
Go to the source code of this file.
Copyright (C) 2007 iRex Technologies BV.
Definition in file connectPing.h.
typedef int get_initial_profile_t(void) |
Definition at line 56 of file connectPing.h.
typedef int get_n_network_profiles_t(void) |
Definition at line 59 of file connectPing.h.
typedef const networkProfile_t* get_network_profile_t(int profileIndex) |
Definition at line 60 of file connectPing.h.
typedef void on_connected_t(int profileIndex) |
Definition at line 70 of file connectPing.h.
typedef void on_failed_all_t(void) |
Definition at line 71 of file connectPing.h.
typedef gboolean select_next_regprofile_t(int profileIndex) |
Definition at line 61 of file connectPing.h.
typedef void ui_display_settings_t(int profileIndex, gboolean resetStatus) |
Definition at line 65 of file connectPing.h.
typedef void ui_select_profile_t(int profileIndex) |
Definition at line 66 of file connectPing.h.
typedef void ui_unselect_all_profile_t(void) |
Definition at line 67 of file connectPing.h.
typedef void ui_update_status_t(int profileIndex, pingStatus_t status) |
Definition at line 64 of file connectPing.h.
enum pingMode_t |
Definition at line 33 of file connectPing.h.
00034 { 00035 backgroundPing_e = 0, 00036 connectPing_e, 00037 editPing_e, 00038 undefPingMode_e 00039 }pingMode_t;
enum pingStatus_t |
pingSucceeded_e | |
pingFailed_e | |
pingFailedPCShare_e | |
pingFailedNetwork_e | |
pingSkipped_e | |
pingNeedKey_e | |
pingAborting_e | |
pingAborted_e | |
pingConnecting_e | |
undefPingStatus_e |
Definition at line 41 of file connectPing.h.
00042 { 00043 pingSucceeded_e=0, 00044 pingFailed_e, 00045 pingFailedPCShare_e, 00046 pingFailedNetwork_e, 00047 pingSkipped_e, 00048 pingNeedKey_e, 00049 pingAborting_e, 00050 pingAborted_e, 00051 pingConnecting_e, 00052 undefPingStatus_e 00053 }pingStatus_t;
void connect_ping | ( | pingContext_t * | ctxt, | |
gboolean | delay | |||
) |
Definition at line 429 of file connectPing.c.
00430 { 00431 CN_LOGPRINTF ("entry delay[%d]", delay); 00432 00433 g_return_if_fail(ctxt != NULL); 00434 00435 if (ctxt->pingServer) 00436 { 00437 CN_WARNPRINTF("Please wait while pinging..."); 00438 return; 00439 } 00440 00441 if (delay) 00442 { 00443 if (ctxt->pingTimeoutId > 0) 00444 { 00445 CN_LOGPRINTF("remove the old timeout function for pinging"); 00446 g_source_remove(ctxt->pingTimeoutId); 00447 ctxt->pingTimeoutId = 0; 00448 } 00449 00450 // begin to ping after 'delay' timeout 00451 ctxt->pingTimeoutId = g_timeout_add(delay, 00452 connect_ping_start, 00453 (gpointer)ctxt); 00454 } 00455 else 00456 { 00457 connect_ping_start(ctxt); 00458 } 00459 }
void connect_ping_abort | ( | pingContext_t * | ctxt | ) |
Definition at line 627 of file connectPing.c.
00628 { 00629 CN_LOGPRINTF ("entry"); 00630 00631 g_return_if_fail(ctxt != NULL); 00632 00633 if (ctxt->pingServer) 00634 { 00635 CN_WARNPRINTF("Abort pinging..."); 00636 00637 gint profileIndex = connect_ping_get_pinging_profile_index(ctxt); 00638 00639 if (ctxt->mode != backgroundPing_e && ctxt->ui_update_status) 00640 { 00641 // update the ui 00642 ctxt->ui_update_status(profileIndex, pingAborting_e); 00643 } 00644 00645 // stop the pingThread 00646 pingThread_stop(); 00647 00648 // wait for pingThread done 00649 ctxt->pingAborting = TRUE; 00650 g_timeout_add(200, delay_connect_ping_abort, (gpointer)ctxt); 00651 } 00652 }
void connect_ping_ctxt_destory | ( | pingContext_t * | ctxt | ) |
Definition at line 167 of file connectPing.c.
00168 { 00169 ping_thread_parms *pingParms; 00170 00171 if (ctxt) 00172 { 00173 if (ctxt->pingParms) 00174 { 00175 pingParms = ctxt->pingParms; 00176 free_network_pc_settings(pingParms); 00177 /* 00178 if (pingParms->pingStatus) 00179 { 00180 gtk_widget_destroy(pingParms->pingStatus); 00181 } 00182 */ 00183 00184 g_free(pingParms); 00185 } 00186 g_free(ctxt); 00187 } 00188 }
pingContext_t* connect_ping_ctxt_new | ( | void | ) |
Definition at line 51 of file connectPing.c.
00052 { 00053 pingContext_t *ctxt; 00054 GtkWidget *pingStatus; 00055 00056 CN_LOGPRINTF("entry"); 00057 00058 ctxt = g_new0(pingContext_t, 1); 00059 g_assert(ctxt != NULL); 00060 00061 // set the default values 00062 connect_ping_ctxt_set_mode(ctxt, undefPingMode_e); 00063 connect_ping_ctxt_set_connect_type(ctxt, cmgrConnectUnknown_e); 00064 connect_ping_ctxt_set_done_callbacks(ctxt, NULL, NULL); 00065 00066 ctxt->selectedProfileIndex = -1; 00067 ctxt->pingingProfileIndexStart = -1; 00068 ctxt->pingingProfileIndex = -1; 00069 00070 // initilize the pingParms 00071 ctxt->pingParms = g_new0(ping_thread_parms, 1); 00072 g_assert(ctxt->pingParms != NULL); 00073 00074 // ctxt->pingParms->pingStatus 00075 pingStatus = gtk_label_new ("ping-idle"); 00076 g_signal_connect(pingStatus, "notify", 00077 G_CALLBACK (on_ping_status_changed), ctxt); 00078 ctxt->pingParms->pingStatus = pingStatus; 00079 00080 // the other values are set to be NULL or zero implicitly by g_new0 00081 00082 return ctxt; 00083 }
void connect_ping_ctxt_set_access_network_profiles_callbacks | ( | pingContext_t * | ctxt, | |
get_n_network_profiles_t * | get_n_network_profiles, | |||
get_network_profile_t * | get_network_profile, | |||
select_next_regprofile_t * | select_next_regprofile | |||
) |
Definition at line 111 of file connectPing.c.
00115 { 00116 if (ctxt) 00117 { 00118 ctxt->get_n_network_profiles = get_n_network_profiles; 00119 ctxt->get_network_profile = get_network_profile; 00120 ctxt->select_next_regprofile = select_next_regprofile; 00121 } 00122 }
void connect_ping_ctxt_set_connect_type | ( | pingContext_t * | ctxt, | |
cmgrConnectType_t | connectType | |||
) |
Definition at line 93 of file connectPing.c.
00095 { 00096 if (ctxt && (connectType >= 0) && (connectType < cmgrConnectUndef_e)) 00097 { 00098 ctxt->connectType = connectType; 00099 } 00100 }
void connect_ping_ctxt_set_done_callbacks | ( | pingContext_t * | ctxt, | |
on_connected_t * | on_connected, | |||
on_failed_all_t * | on_failed_all | |||
) |
Definition at line 139 of file connectPing.c.
00142 { 00143 if (ctxt) 00144 { 00145 ctxt->on_connected = on_connected; 00146 ctxt->on_failed_all = on_failed_all; 00147 } 00148 }
void connect_ping_ctxt_set_get_initial_profile | ( | pingContext_t * | ctxt, | |
get_initial_profile_t * | get_initial_profile | |||
) |
Definition at line 102 of file connectPing.c.
00104 { 00105 if (ctxt) 00106 { 00107 ctxt->get_initial_profile = get_initial_profile; 00108 } 00109 }
void connect_ping_ctxt_set_mode | ( | pingContext_t * | ctxt, | |
pingMode_t | mode | |||
) |
Definition at line 85 of file connectPing.c.
00086 { 00087 if (ctxt && (mode >= 0) && (mode < undefPingMode_e)) 00088 { 00089 ctxt->mode = mode; 00090 } 00091 }
void connect_ping_ctxt_set_ui_callbacks | ( | pingContext_t * | ctxt, | |
ui_update_status_t * | ui_update_status, | |||
ui_display_settings_t * | ui_display_settings, | |||
ui_select_profile_t * | ui_select_profile, | |||
ui_unselect_all_profile_t * | ui_unselect_all_profile | |||
) |
Definition at line 124 of file connectPing.c.
00129 { 00130 if (ctxt) 00131 { 00132 ctxt->ui_update_status = ui_update_status; 00133 ctxt->ui_display_settings = ui_display_settings; 00134 ctxt->ui_select_profile = ui_select_profile; 00135 ctxt->ui_unselect_all_profile = ui_unselect_all_profile; 00136 } 00137 }
gboolean connect_ping_freeze_ui | ( | pingContext_t * | ctxt | ) |
Definition at line 585 of file connectPing.c.
00586 { 00587 g_return_val_if_fail(ctxt != NULL, FALSE); 00588 00589 CN_LOGPRINTF("return freeze = %d", ctxt->pingAborting); 00590 return ctxt->pingAborting; 00591 }
int connect_ping_get_pinging_profile_index | ( | pingContext_t * | ctxt | ) |
Definition at line 212 of file connectPing.c.
00213 { 00214 g_return_val_if_fail(ctxt != NULL, -1); 00215 00216 CN_LOGPRINTF("entry profileIndex=%d", ctxt->pingingProfileIndex); 00217 00218 return ctxt->pingingProfileIndex; 00219 }
int connect_ping_get_pinging_profile_index_start | ( | pingContext_t * | ctxt | ) |
Definition at line 193 of file connectPing.c.
00194 { 00195 g_return_val_if_fail(ctxt != NULL, -1); 00196 00197 CN_LOGPRINTF("entry profileIndex=%d", ctxt->pingingProfileIndexStart); 00198 00199 return ctxt->pingingProfileIndexStart; 00200 }
int connect_ping_get_selected_profile_index | ( | pingContext_t * | ctxt | ) |
Definition at line 231 of file connectPing.c.
00232 { 00233 g_return_val_if_fail(ctxt != NULL, -1); 00234 00235 CN_LOGPRINTF("entry profileIndex=%d", ctxt->selectedProfileIndex); 00236 00237 return ctxt->selectedProfileIndex; 00238 }
gboolean connect_ping_in_pinging | ( | pingContext_t * | ctxt | ) |
Definition at line 461 of file connectPing.c.
00462 { 00463 g_return_val_if_fail(ctxt, FALSE); 00464 00465 CN_LOGPRINTF("return [%d]", ctxt->pingServer); 00466 return ctxt->pingServer; 00467 }
void connect_ping_select_initial_profile | ( | pingContext_t * | ctxt | ) |
Definition at line 381 of file connectPing.c.
00382 { 00383 CN_LOGPRINTF ("entry"); 00384 00385 int profileIndex = 0; 00386 cmgrConnectType_t connectType; 00387 00388 g_return_if_fail(ctxt != NULL); 00389 00390 // select initial profile to use when connecting 00391 connectType = ctxt->connectType; 00392 if (connectType == cmgrConnectUnknown_e) 00393 { 00394 CN_WARNPRINTF("Unknown connect type[%d].", connectType); 00395 00396 // edit mode of iDS/PC unknown: no profile selected 00397 connect_ping_unselect_profile (ctxt); 00398 } 00399 else 00400 { 00401 if (ctxt->get_initial_profile) 00402 { 00403 profileIndex = ctxt->get_initial_profile(); 00404 } 00405 00406 connect_ping_select_profile(ctxt, profileIndex); 00407 connect_ping_set_pinging_profile_index_start(ctxt, profileIndex); 00408 00409 if (ctxt->mode != backgroundPing_e && ctxt->ui_select_profile) 00410 { 00411 ctxt->ui_select_profile(profileIndex); 00412 } 00413 } 00414 }
void connect_ping_set_pinging_profile_index | ( | pingContext_t * | ctxt, | |
int | profileIndex | |||
) |
Definition at line 221 of file connectPing.c.
00223 { 00224 g_return_if_fail(ctxt != NULL); 00225 00226 CN_LOGPRINTF("entry profileIndex[%d]", profileIndex); 00227 00228 ctxt->pingingProfileIndex = profileIndex; 00229 }
void connect_ping_set_pinging_profile_index_start | ( | pingContext_t * | ctxt, | |
int | profileIndex | |||
) |
Definition at line 202 of file connectPing.c.
00204 { 00205 g_return_if_fail(ctxt != NULL); 00206 00207 CN_LOGPRINTF("entry[%d]", profileIndex); 00208 00209 ctxt->pingingProfileIndexStart = profileIndex; 00210 }
void connect_ping_set_selected_profile_index | ( | pingContext_t * | ctxt, | |
int | profileIndex | |||
) |
Definition at line 240 of file connectPing.c.
00242 { 00243 g_return_if_fail(ctxt != NULL); 00244 00245 CN_LOGPRINTF("entry profileIndex[%d]", profileIndex); 00246 00247 ctxt->selectedProfileIndex = profileIndex; 00248 }