Changeset 1521
- Timestamp:
- 01/30/07 20:19:03
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/camel-service.c (modified) (2 diffs)
- trunk/libtinymail-camel/camel-lite/camel/camel-service.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-account.c (modified) (3 diffs)
- trunk/libtinymail-camel/tny-camel-store-account.c (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-transport-account.c (modified) (1 diff)
- trunk/libtinymail-camel/tny-session-camel-priv.h (modified) (2 diffs)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (7 diffs)
- trunk/libtinymail-camel/tny-session-camel.h (modified) (1 diff)
- trunk/tests/shared/account-store.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1517 r1521 2 2 3 3 * Little bugfix. Max line size of an E-mail is now MAX_LINE_SIZE 4 * Cleaning up old code, fixing bug in the tny-session-camel.c 4 5 5 6 2007-01-29 Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com> trunk/libtinymail-camel/camel-lite/camel/camel-service.c
r1025 r1521 92 92 { 93 93 CamelService *service = o; 94 94 95 service->data = NULL; 95 96 service->priv = g_malloc0(sizeof(*service->priv)); 96 97 g_static_rec_mutex_init(&service->priv->connect_lock); … … 119 120 if (service->session) 120 121 camel_object_unref (service->session); 121 122 service->data = NULL; 123 122 124 g_static_rec_mutex_free (&service->priv->connect_lock); 123 125 g_static_mutex_free (&service->priv->connect_op_lock); trunk/libtinymail-camel/camel-lite/camel/camel-service.h
r1014 r1521 73 73 CamelOperation *connect_op; 74 74 CamelURL *url; 75 gpointer data; 75 76 }; 76 77 trunk/libtinymail-camel/tny-camel-account.c
r1500 r1521 473 473 g_static_rec_mutex_lock (priv->service_lock); 474 474 475 tny_session_camel_set_pass_func (priv->session, self, get_pass_func);476 475 priv->get_pass_func = get_pass_func; 477 476 priv->pass_func_set = TRUE; … … 497 496 g_static_rec_mutex_lock (priv->service_lock); 498 497 499 tny_session_camel_set_forget_pass_func (priv->session, self, get_forget_pass_func);500 498 priv->forget_pass_func = get_forget_pass_func; 501 499 priv->forget_pass_func_set = TRUE; … … 671 669 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 672 670 671 priv->get_pass_func = NULL; 672 priv->forget_pass_func = NULL; 673 673 priv->port = -1; 674 674 priv->cache_location = NULL; trunk/libtinymail-camel/tny-camel-store-account.c
r1511 r1521 118 118 if (apriv->session) 119 119 { 120 CamelService *oservice = apriv->service; 121 120 122 if (camel_exception_is_set (apriv->ex)) 121 123 camel_exception_clear (apriv->ex); 122 123 if (apriv->service)124 {125 camel_object_unref (CAMEL_OBJECT (apriv->service));126 apriv->service = NULL;127 }128 124 129 125 apriv->service = camel_session_get_service 130 126 ((CamelSession*) apriv->session, apriv->url_string, 131 127 apriv->type, apriv->ex); 128 129 if (apriv->service) 130 apriv->service->data = self; 132 131 133 132 } else { trunk/libtinymail-camel/tny-camel-transport-account.c
r1490 r1521 122 122 if (apriv->session) 123 123 { 124 CamelService *oservice = apriv->service; 125 124 126 if (camel_exception_is_set (apriv->ex)) 125 127 camel_exception_clear (apriv->ex); 126 127 if (apriv->service)128 {129 camel_object_unref (CAMEL_OBJECT (apriv->service));130 apriv->service = NULL;131 }132 128 133 129 apriv->service = camel_session_get_service 134 130 ((CamelSession*) apriv->session, apriv->url_string, 135 131 apriv->type, apriv->ex); 132 133 if (apriv->service) 134 apriv->service->data = self; 136 135 137 136 } else { trunk/libtinymail-camel/tny-session-camel-priv.h
r1511 r1521 11 11 gchar *camel_dir; 12 12 gboolean in_auth_function, is_connecting; 13 gboolean async_connect; 13 14 TnyLockable *ui_lock; 14 15 GMutex *conlock; … … 16 17 }; 17 18 19 void _tny_session_camel_fixup (TnySessionCamel *self, CamelService *oservice, TnyAccount *account); 18 20 void _tny_session_camel_add_account (TnySessionCamel *self, TnyCamelAccount *account); 19 21 void _tny_session_camel_forget_account (TnySessionCamel *self, TnyCamelAccount *account); trunk/libtinymail-camel/tny-session-camel.c
r1511 r1521 55 55 56 56 static CamelSessionClass *ms_parent_class; 57 static GList *password_funcs = NULL;58 static GList *forget_password_funcs = NULL;59 60 typedef struct61 {62 CamelService *service;63 TnyGetPassFunc func;64 TnyAccount *account;65 66 } PrivPassFunc;67 68 typedef struct69 {70 CamelService *service;71 TnyForgetPassFunc func;72 TnyAccount *account;73 74 } PrivForgetPassFunc;75 76 static void77 tny_session_camel_forget_password (CamelSession *session, CamelService *service, const char *domain, const char *item, CamelException *ex);78 79 /**80 * tny_session_camel_set_forget_pass_func:81 * @self: a #TnySessionCamel object82 * @account: the #TnyAccount account instance83 * @get_forget_pass_func: The function that will forget the password for the account84 *85 * For each account you can set a password handler. This makes it possible to86 * use your own password-store implementation for storing passwords. You set87 * the handler that tells that store to forget the password, using this method.88 *89 * It's recommended to also memset (buffer, 0, len) the memory where the90 * password was stored. You can do it in the forget_pass_func handler.91 *92 **/93 void94 tny_session_camel_set_forget_pass_func (TnySessionCamel *self, TnyAccount *account, TnyForgetPassFunc get_forget_pass_func)95 {96 GList *copy = forget_password_funcs, *mark_del = NULL;97 PrivForgetPassFunc *pf;98 gboolean found = FALSE;99 CamelService *service = (CamelService*)_tny_camel_account_get_service (TNY_CAMEL_ACCOUNT (account));100 101 while (G_LIKELY (copy))102 {103 pf = copy->data;104 105 if (G_UNLIKELY (pf->service == NULL) || G_UNLIKELY (pf->account == NULL))106 {107 mark_del = g_list_prepend (mark_del, copy);108 copy = g_list_next (copy);109 continue;110 }111 112 if (G_UNLIKELY (pf->service == service))113 {114 found = TRUE;115 break;116 }117 118 copy = g_list_next (copy);119 }120 121 if (G_UNLIKELY (!found))122 pf = g_new0 (PrivForgetPassFunc, 1);123 124 pf->account = account;125 pf->func = get_forget_pass_func;126 pf->service = service;127 128 if (G_UNLIKELY (!found))129 forget_password_funcs = g_list_prepend (forget_password_funcs, pf);130 131 if (G_UNLIKELY (mark_del))132 {133 while (G_LIKELY (mark_del))134 {135 forget_password_funcs = g_list_remove (forget_password_funcs, mark_del->data);136 mark_del = g_list_next (mark_del);137 }138 139 g_list_free (mark_del);140 }141 142 return;143 }144 145 /**146 * tny_session_camel_set_pass_func:147 * @self: a #TnySessionCamel object148 * @account: the #TnyAccount account instance149 * @get_pass_func: The function that will return the password for the account150 *151 * For each account you can set a password handler. This makes it possible to152 * use your own password-store implementation for storing passwords. You set153 * that password handler method using this method.154 *155 **/156 void157 tny_session_camel_set_pass_func (TnySessionCamel *self, TnyAccount *account, TnyGetPassFunc get_pass_func)158 {159 GList *copy = password_funcs, *mark_del = NULL;160 PrivPassFunc *pf;161 gboolean found = FALSE;162 CamelService *service = (CamelService*)_tny_camel_account_get_service (TNY_CAMEL_ACCOUNT (account));163 164 while (G_LIKELY (copy))165 {166 pf = copy->data;167 168 if (G_UNLIKELY (pf->service == NULL) || G_UNLIKELY (pf->account == NULL) ||169 !CAMEL_IS_SERVICE (pf->service) || !TNY_IS_ACCOUNT (pf->account))170 {171 mark_del = g_list_prepend (mark_del, copy);172 copy = g_list_next (copy);173 continue;174 }175 176 if (G_UNLIKELY (pf->service == service))177 {178 found = TRUE;179 break;180 }181 182 copy = g_list_next (copy);183 }184 185 if (G_UNLIKELY (!found))186 pf = g_new0 (PrivPassFunc, 1);187 188 pf->account = account;189 pf->func = get_pass_func;190 pf->service = service;191 192 if (G_UNLIKELY (!found))193 password_funcs = g_list_prepend (password_funcs, pf);194 195 if (G_UNLIKELY (mark_del))196 {197 while (G_LIKELY (mark_del))198 {199 password_funcs = g_list_remove (password_funcs, mark_del->data);200 mark_del = g_list_next (mark_del);201 }202 g_list_free (mark_del);203 }204 205 return;206 }207 57 208 58 static char * … … 213 63 TnySessionCamelPriv *priv = self->priv; 214 64 215 GList *copy = password_funcs;216 65 TnyGetPassFunc func; 217 66 TnyAccount *account; 218 gboolean f ound = FALSE, freeprmpt = FALSE, cancel = FALSE;67 gboolean freeprmpt = FALSE, cancel = FALSE; 219 68 gchar *retval = NULL, *prmpt = (gchar*)prompt; 220 GThread *thread; 221 222 while (G_LIKELY (copy)) 223 { 224 PrivPassFunc *pf = copy->data; 225 226 if (G_UNLIKELY (pf->service == service) && pf->account) 227 { 228 found = TRUE; 229 func = pf->func; 230 account = pf->account; 231 break; 232 } 233 234 copy = g_list_next (copy); 235 } 236 237 if (G_LIKELY (found)) 238 { 69 70 account = service->data; 71 if (account) 72 { 73 74 func = tny_account_get_pass_func (account); 75 76 if (!func) 77 return g_strdup (""); 78 239 79 if (prmpt == NULL) 240 80 { … … 266 106 } 267 107 108 emptypass: 109 268 110 return retval; 269 111 } … … 298 140 TnySessionCamelPriv *priv = self->priv; 299 141 300 GList *copy = forget_password_funcs;301 142 TnyForgetPassFunc func; 302 143 TnyAccount *account; 303 gboolean found = FALSE; 304 GThread *thread; 305 306 while (G_LIKELY (copy)) 307 { 308 PrivForgetPassFunc *pf = copy->data; 309 310 if (G_UNLIKELY (pf->service == service) && pf->account) 311 { 312 found = TRUE; 313 func = pf->func; 314 account = pf->account; 315 break; 316 } 317 copy = g_list_next (copy); 318 } 319 320 if (G_LIKELY (found)) 321 { 144 145 account = service->data; 146 147 if (account) 148 { 149 func = tny_account_get_forget_pass_func (account); 150 151 if (!func) 152 return; 153 322 154 tny_lockable_lock (self->priv->ui_lock); 323 155 func (account); … … 490 322 } 491 323 324 /** 325 * tny_session_camel_set_async_connecting: 326 * @self: a #TnySessionCamel object 327 * @enable: Whether or not to asynchronously connect 328 * 329 * Set connection strategy 330 **/ 331 void 332 tny_session_camel_set_async_connecting (TnySessionCamel *self, gboolean enable) 333 { 334 g_mutex_lock (self->priv->conlock); 335 self->priv->async_connect = enable; 336 g_mutex_unlock (self->priv->conlock); 337 } 338 492 339 493 340 static void … … 507 354 priv->in_auth_function = FALSE; 508 355 priv->is_connecting = FALSE; 356 priv->async_connect = TRUE; 357 509 358 return; 510 359 } … … 650 499 camel_session_set_online ((CamelSession *) self, online); 651 500 652 priv->conthread = g_thread_create (background_connect_thread, info, TRUE, NULL); 653 654 /* background_connect_thread (info); */ 501 if (priv->async_connect) 502 priv->conthread = g_thread_create (background_connect_thread, info, TRUE, NULL); 503 else 504 background_connect_thread (info); 655 505 656 506 return; trunk/libtinymail-camel/tny-session-camel.h
r1501 r1521 49 49 CamelType tny_session_camel_get_type (void); 50 50 51 void tny_session_camel_set_pass_func (TnySessionCamel *self, TnyAccount *account, TnyGetPassFunc get_pass_func);52 void tny_session_camel_set_forget_pass_func (TnySessionCamel *self, TnyAccount *account, TnyForgetPassFunc get_forget_pass_func);53 51 void tny_session_camel_set_account_store (TnySessionCamel *self, TnyAccountStore *account_store); 54 52 void tny_session_camel_set_device (TnySessionCamel *self, TnyDevice *device); 55 53 void tny_session_camel_set_ui_locker (TnySessionCamel *self, TnyLockable *ui_lock); 56 54 void tny_session_camel_join_connecting (TnySessionCamel *self); 55 void tny_session_camel_set_async_connecting (TnySessionCamel *self, gboolean enable); 57 56 58 57 G_END_DECLS trunk/tests/shared/account-store.c
r1502 r1521 90 90 me->cache_dir = str; 91 91 att++; 92 } while (dir != NULL); 92 } while (dir != NULL); 93 93 } 94 94 … … 146 146 } 147 147 148 if (me->force_online) 149 tny_device_force_online (me->device); 150 else 151 tny_device_force_offline (me->device); 152 148 153 return; 149 154 } … … 164 169 165 170 self->session = tny_session_camel_new (TNY_ACCOUNT_STORE (self)); 171 tny_session_camel_set_async_connecting (self->session, FALSE); 172 166 173 self->force_online = force_online; 167 174 168 if (self->force_online)169 tny_device_force_online (self->device);170 else171 tny_device_force_offline (self->device);172 175 173 176 return TNY_ACCOUNT_STORE (self);
