Changeset 578
- Timestamp:
- 07/26/06 12:24:39
- Files:
-
- trunk/configure.ac (modified) (7 diffs)
- trunk/libtinymail-olpc/tny-account-store.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/configure.ac
r530 r578 51 51 AC_PROG_LIBTOOL 52 52 53 dnl ### default value 54 build_gnome=true 55 56 dnl ### Select the platform library ## 57 AC_ARG_WITH(platform, 58 [ --with-platform=gnome-desktop platform to compile [gnome-desktop]], 59 [case "${with_platform}" in 60 gnome-desktop) PLATFORMDIR=libtinymail-gnome-desktop ;; 61 olpc) 62 PLATFORMDIR=libtinymail-olpc 63 build_gtkhtml=false 64 build_mozembed=false 65 build_gnome=false 66 with_html_component=none 67 ;; 68 maemo) 69 PLATFORMDIR=libtinymail-maemo 70 build_gtkhtml=false 71 build_mozembed=false 72 build_gnome=false 73 with_html_component=none 74 ;; 75 gpe) PLATFORMDIR=libtinymail-gpe ;; 76 *) PLATFORMDIR=${with_platform} 77 esac], [PLATFORMDIR=libtinymail-gnome-desktop 78 with_platform=gnome-desktop]) 79 AC_SUBST(PLATFORMDIR) 80 53 81 54 82 dnl ### Enable gnome features ## … … 59 87 no) build_gnome=false ;; 60 88 *) AC_MSG_ERROR(bad value ${enableval} for --enable-gnome) ;; 61 esac],[build_gnome= true])89 esac],[build_gnome=$build_gnome]) 62 90 AM_CONDITIONAL(BUILD_GNOME, test x$build_gnome = xtrue) 63 91 … … 106 134 AM_CONDITIONAL(BUILD_UNITTESTS, test x$build_unittests = xtrue) 107 135 108 dnl ### Select the platform library ##109 AC_ARG_WITH(platform,110 [ --with-platform=gnome-desktop platform to compile [gnome-desktop]],111 [case "${with_platform}" in112 gnome-desktop) PLATFORMDIR=libtinymail-gnome-desktop ;;113 olpc) PLATFORMDIR=libtinymail-olpc ;;114 maemo) PLATFORMDIR=libtinymail-maemo ;;115 gpe) PLATFORMDIR=libtinymail-gpe ;;116 *) PLATFORMDIR=${with_platform}117 esac], [PLATFORMDIR=libtinymail-gnome-desktop118 with_platform=gnome-desktop])119 AC_SUBST(PLATFORMDIR)120 121 136 dnl ### gtk-doc 122 137 GTK_DOC_CHECK([1.0]) … … 179 194 dnl ### libtinymail-olpc, a platform library implementation for the One Laptop Per Child device ## 180 195 if test x$PLATFORMDIR = xlibtinymail-olpc; then 181 PKG_CHECK_MODULES(LIBTINYMAIL_OLPC, g conf-2.0 glib-2.0 >= 2.8 gobject-2.0 gconf-2.0 gtk+-2.0)196 PKG_CHECK_MODULES(LIBTINYMAIL_OLPC, glib-2.0 >= 2.8 gobject-2.0 gtk+-2.0) 182 197 else 183 198 LIBTINYMAIL_OLPC_CFLAGS= … … 190 205 dnl ### libtinymail-maemo, a platform library implementation for the maemo platform ## 191 206 if test x$PLATFORMDIR = xlibtinymail-maemo; then 192 PKG_CHECK_MODULES(LIBTINYMAIL_MAEMO, g conf-2.0 glib-2.0 >= 2.8 gobject-2.0 gconf-2.0 gtk+-2.0)207 PKG_CHECK_MODULES(LIBTINYMAIL_MAEMO, glib-2.0 >= 2.8 gobject-2.0 gconf-2.0 gtk+-2.0) 193 208 else 194 209 LIBTINYMAIL_MAEMO_CFLAGS= … … 200 215 dnl ### libtinymail-gpe, a platform library implementation for the GPE platform ## 201 216 if test x$PLATFORMDIR = xlibtinymail-gpe; then 202 PKG_CHECK_MODULES(LIBTINYMAIL_GPE, g conf-2.0 glib-2.0 >= 2.8 gobject-2.0 gconf-2.0 gtk+-2.0)217 PKG_CHECK_MODULES(LIBTINYMAIL_GPE, glib-2.0 >= 2.8 gobject-2.0 gconf-2.0 gtk+-2.0) 203 218 else 204 219 LIBTINYMAIL_GPE_CFLAGS= … … 223 238 224 239 dnl ### tinymail, the demo-ui ## 225 dnl Try to remove the gtk+ and gconf dependency by refactoring to libraries 226 PKG_CHECK_MODULES(TINYMAIL, glib-2.0 >= 2.6 gobject-2.0 gconf-2.0 gtk+-2.0 $extratnypkgs) 240 PKG_CHECK_MODULES(TINYMAIL, glib-2.0 >= 2.6 gobject-2.0 gtk+-2.0 $extratnypkgs) 227 241 AC_SUBST(TINYMAIL_CFLAGS) 228 242 AC_SUBST(TINYMAIL_LIBS) trunk/libtinymail-olpc/tny-account-store.c
r551 r578 24 24 #include <glib.h> 25 25 #include <gtk/gtk.h> 26 #include <gconf/gconf-client.h>27 26 28 27 #include <tny-platform-factory-iface.h> … … 52 51 struct _TnyAccountStorePriv 53 52 { 54 GConfClient *client;55 gchar *cache_dir;56 53 TnySessionCamel *session; 57 54 TnyDeviceIface *device; … … 78 75 if (G_UNLIKELY (!retval)) 79 76 { 80 /* This crashes on subsequent calls (any gtk widget creation does) */81 77 GtkDialog *dialog = GTK_DIALOG (tny_password_dialog_new ()); 82 78 … … 168 164 } 169 165 170 static void171 gconf_listener_account_changed (GConfClient *client, guint cnxn_id,172 GConfEntry *entry, gpointer user_data)173 {174 TnyAccountStoreIface *self = user_data;175 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self);176 177 178 gchar *key = g_strdup (entry->key);179 gchar *ptr = strrchr (key, '/'); ptr++;180 181 if (!strcmp (ptr, "count"))182 {183 g_signal_emit (self,184 tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNTS_RELOADED], 0);185 186 }187 188 g_free (key);189 190 return;191 }192 193 166 194 167 static const gchar* 195 168 tny_account_store_get_cache_dir (TnyAccountStoreIface *self) 196 169 { 197 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 198 199 if (G_UNLIKELY (!priv->cache_dir)) 200 { 201 /* Note that there's no listener for this key. If it changes, 202 the camelsession should be destroyed and rebuild from scratch. 203 Which basically means reloading the accounts aswell. 204 205 So say you're a nut who wants this key to be updatable at 206 runtime, you'll have to unload all the accounts here, and of 207 course reload them. All the functionality for that is already 208 available. Perhaps I should just do it ... hmm, maybe another 209 day. Soon. Perhaps. I don't know. Probably . . . . bleh. 210 211 Oh and, not to forget! You should probably also move the old 212 cache location to the new one. Or cleanup the old one. */ 213 214 gchar *cache_dir = gconf_client_get_string (priv->client, 215 "/apps/tinymail/cache_dir", NULL); 216 priv->cache_dir = g_build_filename (g_get_home_dir (), 217 cache_dir, NULL); 218 g_free (cache_dir); 219 } 220 221 return priv->cache_dir; 170 return g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir(), ".tinymail"); 222 171 } 223 172 … … 228 177 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 229 178 gint i=0, count; 230 231 count = gconf_client_get_int (priv->client, 232 "/apps/tinymail/accounts/count", NULL); 233 234 for (i=0; i < count; i++) 235 { 236 gchar *proto, *type, *key, *name; 179 const gchar *filen; 180 gchar *configd; 181 gchar *key = NULL; 182 GDir *dir ; 183 184 configd = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir(), 185 ".tinymail", "accounts"); 186 dir = g_dir_open (configd, 0, NULL); 187 g_free (configd); 188 189 if (!dir) 190 return; 191 192 for (filen = g_dir_read_name (dir); filen; filen = g_dir_read_name (dir)) 193 { 194 FILE *file = fopen (filen, "r"); 195 196 if (file) 197 { 198 gchar *tok, proto[200], type[200], key[200], name[200], options[1000]; 237 199 TnyAccountIface *account = NULL; 238 GSList *options; 239 240 key = g_strdup_printf ("/apps/tinymail/accounts/%d", i); 241 242 if (!gconf_client_dir_exists (priv->client, (const gchar*)key, NULL)) 243 { 244 g_free (key); 245 continue; 246 } 247 g_free (key); 248 249 key = g_strdup_printf ("/apps/tinymail/accounts/%d/type", i); 250 type = gconf_client_get_string (priv->client, 251 (const gchar*) key, NULL); 252 g_free (key); 200 201 fscanf (file, "type=%s", &type); 253 202 254 203 if (type && G_LIKELY (!g_ascii_strncasecmp (type, "transport", 9))) … … 275 224 tny_account_iface_set_account_store (account, self); 276 225 277 if (type) 278 g_free (type); 279 280 key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 281 proto = gconf_client_get_string (priv->client, 282 (const gchar*) key, NULL); 283 g_free (key); 226 fscanf (file, "proto=%s", &proto); 284 227 tny_account_iface_set_proto (TNY_ACCOUNT_IFACE (account), proto); 285 228 286 key = g_strdup_printf ("/apps/tinymail/accounts/%d/name", i); 287 name = gconf_client_get_string (priv->client, 288 (const gchar*) key, NULL); 289 g_free (key); 229 fscanf (file, "name=%s", &name); 290 230 tny_account_iface_set_name (TNY_ACCOUNT_IFACE (account), name); 291 g_free (name); 292 293 294 key = g_strdup_printf ("/apps/tinymail/accounts/%d/options", i); 295 options = gconf_client_get_list (priv->client, 296 (const gchar*) key, GCONF_VALUE_STRING, NULL); 297 g_free (key); 298 299 if (options) 231 232 233 fscanf (file, "options=%s", &options); 234 tok = strtok (options, ","); 235 236 while (tok) 300 237 { 301 while (options) 302 { 303 tny_account_add_option (TNY_ACCOUNT (account), options->data); 304 g_free (options->data); 305 options = g_slist_next (options); 306 } 307 g_slist_free (options); 238 tny_account_add_option (TNY_ACCOUNT (account), tok); 239 tok = strtok (NULL, ","); 308 240 } 309 241 … … 316 248 317 249 /* TODO: Add other supported and tested providers here */ 318 key = g_strdup_printf ("/apps/tinymail/accounts/%d/user", i); 319 user = gconf_client_get_string (priv->client, 320 (const gchar*) key, NULL); 321 322 g_free (key); 250 fscanf (file, "user=%s", &user); 323 251 tny_account_iface_set_user (TNY_ACCOUNT_IFACE (account), user); 324 252 325 key = g_strdup_printf ("/apps/tinymail/accounts/%d/hostname", i); 326 hostname = gconf_client_get_string (priv->client, 327 (const gchar*) key, NULL); 328 g_free (key); 253 254 fscanf (file, "hostname=%s", &hostname); 329 255 tny_account_iface_set_hostname (TNY_ACCOUNT_IFACE (account), 330 256 hostname); 331 257 332 g_free (hostname); g_free (proto); g_free (user);333 258 } else { 334 259 gchar *url_string; … … 337 262 /* Assuming there's a url_string in this case */ 338 263 339 key = g_strdup_printf ("/apps/tinymail/accounts/%d/url_string", i); 340 url_string = gconf_client_get_string (priv->client, 341 (const gchar*) key, NULL); 342 343 g_free (key); 264 fscanf (file, "url_string=%s", &url_string); 344 265 tny_account_iface_set_url_string (TNY_ACCOUNT_IFACE (account), url_string); 345 g_free (url_string);346 266 } 347 267 348 key = g_strdup_printf ("/apps/tinymail/accounts/%d", i); 349 tny_account_iface_set_id (TNY_ACCOUNT_IFACE (account), key); 350 g_free (key); 268 tny_account_iface_set_id (TNY_ACCOUNT_IFACE (account), filen); 351 269 352 270 /* … … 363 281 tny_list_iface_prepend (list, account); 364 282 } 283 284 fclose (file); 285 } 286 287 } 288 g_dir_close (dir); 289 290 291 tny_session_camel_set_current_accounts (priv->session, list); 292 293 return; 294 } 295 296 297 298 static void 299 tny_account_store_add_account (TnyAccountStoreIface *self, TnyAccountIface *account, const gchar *type) 300 { 301 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 302 gchar *filen = g_build_filename (g_get_home_dir(), ".tinymail", 303 tny_account_iface_get_name (account)); 304 305 FILE *file = fopen (filen, "w"); 306 307 if (file) 308 { 309 310 fprintf (file, "type=%s", type); 311 fprintf (file, "proto=%s", tny_account_iface_get_proto (account)); 312 fprintf (file, "name=%s", tny_account_iface_get_name (account)); 313 fprintf (file, "options="); 314 fprintf (file, "user=%s", tny_account_iface_get_user (account)); 315 fprintf (file, "hostname=%s", tny_account_iface_get_hostname (account)); 316 317 318 fclose (file); 365 319 } 366 320 367 tny_session_camel_set_current_accounts (priv->session, list);368 369 return;370 }371 372 373 static void374 tny_account_store_notify_add (TnyAccountStoreIface *self)375 {376 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self);377 priv->notify = gconf_client_notify_add (priv->client,378 "/apps/tinymail/accounts", gconf_listener_account_changed,379 self, NULL, NULL);380 return;381 }382 383 static void384 tny_account_store_notify_remove (TnyAccountStoreIface *self)385 {386 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self);387 gconf_client_notify_remove (priv->client, priv->notify);388 return;389 }390 391 /*392 gconftool-2 -s /apps/tinymail/cache_dir -t string .tinymail393 394 gconftool-2 -s /apps/tinymail/accounts/count -t int COUNT395 gconftool-2 -s /apps/tinymail/accounts/0/proto -t string [smtp|imap|pop]396 gconftool-2 -s /apps/tinymail/accounts/0/type -t string [transport|store]397 398 gconftool-2 -s /apps/tinymail/accounts/0/user -t string username399 gconftool-2 -s /apps/tinymail/accounts/0/hostname -t string mailserver400 or401 gconftool-2 -s /apps/tinymail/accounts/0/url_string -t string url_string402 403 */404 405 static void406 tny_account_store_add_account (TnyAccountStoreIface *self, TnyAccountIface *account, const gchar *type)407 {408 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self);409 gchar *key = NULL;410 gint count = gconf_client_get_int (priv->client, "/apps/tinymail/accounts/count", NULL);411 412 count++;413 414 key = g_strdup_printf ("/apps/tinymail/accounts/%d/hostname", count);415 gconf_client_set_string (priv->client, (const gchar*) key,416 tny_account_iface_get_hostname (account), NULL);417 g_free (key);418 419 key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", count);420 gconf_client_set_string (priv->client, (const gchar*) key,421 tny_account_iface_get_proto (account), NULL);422 g_free (key);423 424 key = g_strdup_printf ("/apps/tinymail/accounts/%d/type", count);425 gconf_client_set_string (priv->client, (const gchar*) key, type, NULL);426 g_free (key);427 428 key = g_strdup_printf ("/apps/tinymail/accounts/%d/user", count);429 gconf_client_set_string (priv->client, (const gchar*) key,430 tny_account_iface_get_user (account), NULL);431 g_free (key);432 433 gconf_client_set_int (priv->client, "/apps/tinymail/accounts/count",434 count, NULL);435 436 321 return; 437 322 } … … 444 329 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 445 330 446 tny_account_store_notify_remove (self);447 331 tny_account_store_add_account (self, TNY_ACCOUNT_IFACE (account), "store"); 448 tny_account_store_notify_add (self);449 332 450 333 g_signal_emit (self, tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNT_INSERTED], 0, account); … … 458 341 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 459 342 460 tny_account_store_notify_remove (self);461 343 tny_account_store_add_account (self, TNY_ACCOUNT_IFACE (account), "transport"); 462 tny_account_store_notify_add (self);463 344 464 345 g_signal_emit (self, tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNT_INSERTED], 0, account); … … 503 384 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 504 385 505 priv->client = gconf_client_get_default ();506 507 gconf_client_add_dir (priv->client, "/apps/tinymail",508 GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);509 510 tny_account_store_notify_add (TNY_ACCOUNT_STORE_IFACE (self));511 386 512 387 return; … … 516 391 static void 517 392 tny_account_store_finalize (GObject *object) 518 { 519 TnyAccountStore *self = (TnyAccountStore *)object; 520 TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 521 522 tny_account_store_notify_remove (TNY_ACCOUNT_STORE_IFACE (self)); 523 g_object_unref (G_OBJECT (priv->client)); 524 525 if (G_LIKELY (priv->cache_dir)) 526 g_free (priv->cache_dir); 527 393 { 528 394 (*parent_class->finalize) (object); 529 395
