| | 65 | |
|---|
| | 66 | |
|---|
| | 67 | typedef struct { |
|---|
| | 68 | TnyCamelAccount *self; |
|---|
| | 69 | } ReconInfo; |
|---|
| | 70 | |
|---|
| | 71 | static gpointer |
|---|
| | 72 | reconnect_thread (gpointer user_data) |
|---|
| | 73 | { |
|---|
| | 74 | ReconInfo *info = (ReconInfo *) user_data; |
|---|
| | 75 | TnyCamelAccount *self = (TnyCamelAccount *) info->self; |
|---|
| | 76 | TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); |
|---|
| | 77 | CamelException ex = CAMEL_EXCEPTION_INITIALISER; |
|---|
| | 78 | |
|---|
| | 79 | apriv->service->reconnecting = TRUE; |
|---|
| | 80 | if (apriv->service->reconnecter) |
|---|
| | 81 | apriv->service->reconnecter (apriv->service, FALSE, apriv->service->data); |
|---|
| | 82 | camel_service_disconnect (apriv->service, FALSE, &ex); |
|---|
| | 83 | if (camel_exception_is_set (&ex)) |
|---|
| | 84 | camel_exception_clear (&ex); |
|---|
| | 85 | camel_service_connect (apriv->service, &ex); |
|---|
| | 86 | if (apriv->service->reconnection) |
|---|
| | 87 | { |
|---|
| | 88 | if (!camel_exception_is_set (&ex)) |
|---|
| | 89 | apriv->service->reconnection (apriv->service, TRUE, apriv->service->data); |
|---|
| | 90 | else |
|---|
| | 91 | apriv->service->reconnection (apriv->service, FALSE, apriv->service->data); |
|---|
| | 92 | } |
|---|
| | 93 | apriv->service->reconnecting = FALSE; |
|---|
| | 94 | |
|---|
| | 95 | g_object_unref (info->self); |
|---|
| | 96 | g_slice_free (ReconInfo, info); |
|---|
| | 97 | return NULL; |
|---|
| | 98 | } |
|---|
| 141 | | apriv->service->reconnecting = TRUE; |
|---|
| 142 | | |
|---|
| 143 | | if (apriv->service->reconnecter) |
|---|
| 144 | | apriv->service->reconnecter (apriv->service, FALSE, apriv->service->data); |
|---|
| 145 | | |
|---|
| 146 | | camel_service_disconnect (apriv->service, FALSE, &ex); |
|---|
| 147 | | if (camel_exception_is_set (&ex)) |
|---|
| 148 | | camel_exception_clear (&ex); |
|---|
| 149 | | |
|---|
| 150 | | camel_service_connect (apriv->service, &ex); |
|---|
| 151 | | if (apriv->service->reconnection) |
|---|
| | 175 | if (TNY_IS_STORE_ACCOUNT (self)) |
|---|
| 153 | | if (!camel_exception_is_set (&ex)) |
|---|
| 154 | | apriv->service->reconnection (apriv->service, TRUE, apriv->service->data); |
|---|
| 155 | | else |
|---|
| 156 | | apriv->service->reconnection (apriv->service, FALSE, apriv->service->data); |
|---|
| | 177 | TnyCamelStoreAccountPriv *aspriv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); |
|---|
| | 178 | ReconInfo *info = g_slice_new0 (ReconInfo); |
|---|
| | 179 | info->self = self; |
|---|
| | 180 | |
|---|
| | 181 | /* thread reference */ |
|---|
| | 182 | g_object_ref (info->self); |
|---|
| | 183 | |
|---|
| | 184 | _tny_camel_queue_launch (aspriv->queue, |
|---|
| | 185 | reconnect_thread, info); |
|---|