#include "mapper-types.h"
#include "bt.h"
#include "ui-common.h"
+#include "db.h"
#include "cb.h"
}
/* 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);
}
/* 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);
#include "db.h"
#include "utils.h"
+sqlite3 *_db=NULL;
+gchar *_mapper_db=NULL;
+
/**
* A simple check to test if a table exists
*
* 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;
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;
#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);
#include "settings.h"
#include "mapper-types.h"
#include "ui-common.h"
+#include "db.h"
#define POI_FONT_SIZE (10)
#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,};
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);
#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;
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;
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;
#include "bt.h"
#include "ui-common.h"
#include "settings.h"
+#include "db.h"
#include "hildon-wrappers.h"
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;
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,
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);
/* 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);
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. */
#include "mapper-types.h"
#include "bt.h"
#include "ui-common.h"
+#include "db.h"
/* Callbacks */
#include "cb.h"