]> err.no Git - mapper/commitdiff
The database is not specific to POIs only so rename/move variables.
authorKaj-Michael Lang <milang@onion.tal.org>
Tue, 19 Jun 2007 09:32:57 +0000 (12:32 +0300)
committerKaj-Michael Lang <milang@onion.tal.org>
Tue, 19 Jun 2007 09:32:57 +0000 (12:32 +0300)
src/cb.c
src/config.c
src/db.c
src/db.h
src/map-poi.c
src/mapper.c
src/poi.c
src/poi.h
src/settings-gui.c
src/ui-common.c

index 7d91d982edf55f7919fb06a64111d95c12fdc7a8..83d3bfb968dc9caa9ecc82888cac9b1c241a7042 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
@@ -31,6 +31,7 @@
 #include "mapper-types.h"
 #include "bt.h"
 #include "ui-common.h"
+#include "db.h"
 
 #include "cb.h"
 
index 0aba52a99f043f7f4c30f3784a429b3932f1579e..29b7ef99d955b132c1b0864dc488630dbf9d3101 100644 (file)
@@ -371,8 +371,8 @@ config_save()
        }
 
        /* Save POI database. */
-       if (_poi_db)
-               gconf_client_set_string(gconf_client, GCONF_KEY_POI_DB, _poi_db, NULL);
+       if (_mapper_db)
+               gconf_client_set_string(gconf_client, GCONF_KEY_POI_DB, _mapper_db, NULL);
        else
                gconf_client_unset(gconf_client, GCONF_KEY_POI_DB, NULL);
 
@@ -727,15 +727,15 @@ void config_init()
        }
 
        /* Get POI Database.  Default is in REPO_DEFAULT_CACHE_BASE */
-       _poi_db = gconf_client_get_string(gconf_client, GCONF_KEY_POI_DB, NULL);
-       if (_poi_db == NULL) {
+       _mapper_db = gconf_client_get_string(gconf_client, GCONF_KEY_POI_DB, NULL);
+       if (_mapper_db == NULL) {
                gchar *poi_base =
                    gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_BASE);
-               _poi_db =
+               _mapper_db =
                    gnome_vfs_uri_make_full_from_relative(poi_base, "poi.db");
                g_free(poi_base);
        }
-       poi_db_connect(&_db, _poi_db);
+       poi_db_connect(&_db, _mapper_db);
 
        _poi_zoom = gconf_client_get_int(gconf_client,
                                         GCONF_KEY_POI_ZOOM, NULL);
index 29ef530b0f6d9e4522a9efd088560a9b3a36d90d..c8045b2f492929d06c1ef17aa5acc23f912bc2d9 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -6,6 +6,9 @@
 #include "db.h"
 #include "utils.h"
 
+sqlite3 *_db=NULL;
+gchar *_mapper_db=NULL;
+
 /**
  * A simple check to test if a table exists
  *
@@ -42,7 +45,7 @@ return TRUE;
  * Connect to given sqlite database
  *
  */
-gboolean db_connect(sqlite3 **ndb, const gchar *db_file)
+gboolean db_connect(sqlite3 **ndb, const gchar *mapper_db)
 {
 sqlite3 *db;
 
@@ -58,10 +61,10 @@ if (db) {
        db = NULL;
 }
 
-if (!db_file)
+if (!mapper_db)
        return FALSE;
 
-if (SQLITE_OK != (sqlite3_open(db_file, &db))) {
+if (SQLITE_OK != (sqlite3_open(mapper_db, &db))) {
        sqlite3_close(db);
        db = NULL;
        *ndb=db;
index ea53d82bdd591ea8c999369ebfc4c180e99037fc..9c846083a6ea158cab22d22c9bc7933bc192072e 100644 (file)
--- a/src/db.h
+++ b/src/db.h
@@ -4,7 +4,10 @@
 #ifndef _MAPPER_DB_H
 #define _MAPPER_DB_H
 
-gboolean db_connect(sqlite3 **db, const gchar *poi_db);
+sqlite3 *_db;
+gchar *_mapper_db;
+
+gboolean db_connect(sqlite3 **db, const gchar *mapper_db);
 gboolean db_check(sqlite3 *db, const gchar *table);
 gboolean db_close(sqlite3 **db);
 
index 040dd631217e1f2acc24b42088aacc60a78c5f16..7f55a13f97940295d27ab28bd06c8b186d91126f 100644 (file)
@@ -12,6 +12,7 @@
 #include "settings.h"
 #include "mapper-types.h"
 #include "ui-common.h"
+#include "db.h"
 
 #define POI_FONT_SIZE  (10)
 
index a77ded454c2af1236a70b268f5d16677e1e9f40e..85bcd451045e13e1fcdd5cb7f437d5914bc7e563 100644 (file)
@@ -75,6 +75,7 @@
 #include "map.h"
 #include "bt.h"
 #include "ui-common.h"
+#include "db.h"
 #include "cb.h"
 
 gfloat UNITS_CONVERT[] = {1.85200,1.15077945,1.f,};
@@ -174,10 +175,7 @@ void mapper_destroy(void)
        rcvr_disconnect();
        /* _program and widgets have already been destroyed. */
 
-       if (_db) {
-               sqlite3_close(_db);
-               _db = NULL;
-       }
+       db_close(&_db);
 
        MACRO_PATH_FREE(_track);
        MACRO_PATH_FREE(_route);
index 5ba26d337edfbf0cdbd8f5157229a97f10b2ec9e..5ed882eec8784a9f7f3c498d239eaa37569450c5 100644 (file)
--- a/src/poi.c
+++ b/src/poi.c
@@ -29,9 +29,6 @@
 #include "settings.h"
 #include "db.h"
 
-sqlite3 *_db = NULL;
-gchar *_poi_db = NULL;
-
 sqlite3_stmt *_stmt_select_poi = NULL;
 sqlite3_stmt *_stmt_select_nearest_poi = NULL;
 sqlite3_stmt *_stmt_insert_poi = NULL;
index a38b2adfa280a283c597643ee6606c8bbb846c92..6f5ef0aab5c5fcbf99904151013966a4312d803a 100644 (file)
--- a/src/poi.h
+++ b/src/poi.h
@@ -107,11 +107,9 @@ struct _DeletePOI {
        guint id;
 };
 
-/** POI */
-sqlite3 *_db;
-gchar *_poi_db;
 guint _poi_zoom;
 
+/* POI SQL statements */
 sqlite3_stmt *_stmt_select_poi;
 sqlite3_stmt *_stmt_select_nearest_poi;
 sqlite3_stmt *_stmt_insert_poi;
@@ -120,6 +118,7 @@ sqlite3_stmt *_stmt_delete_poi;
 sqlite3_stmt *_stmt_delete_poi_by_catid;
 sqlite3_stmt *_stmt_nextlabel_poi;
 
+/* Category SQL statements */
 sqlite3_stmt *_stmt_select_cat;
 sqlite3_stmt *_stmt_insert_cat;
 sqlite3_stmt *_stmt_update_cat;
index c5a46b92097c0efa48f3be4b691b322f1b24a7a5..69112e6723e43ecfb7ebec0535186c2ff41815f4 100644 (file)
@@ -30,6 +30,7 @@
 #include "bt.h"
 #include "ui-common.h"
 #include "settings.h"
+#include "db.h"
 
 #include "hildon-wrappers.h"
 
@@ -400,7 +401,7 @@ gboolean settings_dialog()
        GtkWidget *btn_buttons;
        GtkWidget *btn_colors;
 
-       GtkWidget *txt_poi_db;
+       GtkWidget *txt_mapper_db;
        GtkWidget *btn_browsepoi;
        GtkWidget *num_poi_zoom;
        GtkWidget *chk_speed_limit_on;
@@ -688,7 +689,7 @@ gboolean settings_dialog()
                         hbox = gtk_hbox_new(FALSE, 4),
                         1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
        gtk_box_pack_start(GTK_BOX(hbox),
-                          txt_poi_db = gtk_entry_new(), TRUE, TRUE, 0);
+                          txt_mapper_db = gtk_entry_new(), TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(hbox),
                           btn_browsepoi =
                           gtk_button_new_with_label(_("Browse...")), FALSE,
@@ -716,7 +717,7 @@ gboolean settings_dialog()
                         G_CALLBACK(settings_dialog_colors), dialog);
 
        browse_info.dialog = dialog;
-       browse_info.txt = txt_poi_db;
+       browse_info.txt = txt_mapper_db;
        g_signal_connect(G_OBJECT(btn_browsepoi), "clicked",
                         G_CALLBACK(settings_dialog_browse_forfile),
                         &browse_info);
@@ -724,8 +725,8 @@ gboolean settings_dialog()
        /* Initialize fields. */
        if (_rcvr_mac)
                gtk_entry_set_text(GTK_ENTRY(txt_rcvr_mac), _rcvr_mac);
-       if (_poi_db)
-               gtk_entry_set_text(GTK_ENTRY(txt_poi_db), _poi_db);
+       if (_mapper_db)
+               gtk_entry_set_text(GTK_ENTRY(txt_mapper_db), _mapper_db);
 
        hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_poi_zoom),
                                       _poi_zoom);
@@ -825,12 +826,12 @@ gboolean settings_dialog()
                        poi_db_disconnect(&_db);
                        _db = NULL;
                }
-               g_free(_poi_db);
-               if (strlen(gtk_entry_get_text(GTK_ENTRY(txt_poi_db)))) {
-                       _poi_db = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_poi_db)));
-                       poi_db_connect(&_db, _poi_db);
+               g_free(_mapper_db);
+               if (strlen(gtk_entry_get_text(GTK_ENTRY(txt_mapper_db)))) {
+                       _mapper_db = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_mapper_db)));
+                       poi_db_connect(&_db, _mapper_db);
                } else {
-                       _poi_db = NULL;
+                       _mapper_db = NULL;
                }
 
                /* Sensitize menus based on whether we have a POI database conn. */
index fa455f1a63ef89e94c6b7c0b9c4dfe3e5d26fede..90be9c011f087404586e764655b9ff28db9505e1 100644 (file)
@@ -31,6 +31,7 @@
 #include "mapper-types.h"
 #include "bt.h"
 #include "ui-common.h"
+#include "db.h"
 
 /* Callbacks */
 #include "cb.h"