retv_if(!path, NULL);
snprintf(db_file, sizeof(db_file), "%s/%s", path, APP_DB_FILE);
+ free(path);
ret = sqlite3_open(db_file, &db);
if (SQLITE_OK != ret) {
_E("%s", sqlite3_errmsg(db));
- free(path);
return NULL;
}
- free(path);
return db;
}
ret = sqlite3_step(stmt);
switch (ret) {
- case SQLITE_ROW:
+ case SQLITE_ROW: /* SQLITE_ROW : 100 */
return APPL_ERROR_NONE;
- case SQLITE_DONE:
+ case SQLITE_DONE: /* SQLITE_ROW : 101 */
return APPL_ERROR_NO_DATA;
default:
_E("%s", sqlite3_errmsg(db));
int ret = SQLITE_OK;
retv_if(!stmt, APPL_ERROR_FAIL);
- retv_if(!str, APPL_ERROR_FAIL);
- ret = sqlite3_bind_text(stmt, idx, str, strlen(str), SQLITE_TRANSIENT);
+ if (str) {
+ ret = sqlite3_bind_text(stmt, idx, str, -1, SQLITE_TRANSIENT);
+ } else {
+ ret = sqlite3_bind_null(stmt, idx);
+ }
+
if (SQLITE_OK != ret) {
_E("%s", sqlite3_errmsg(db));
return APPL_ERROR_FAIL;
HAPI bool db_get_bool(sqlite3_stmt *stmt, int index)
{
retv_if(!stmt, false);
- return (bool) sqlite3_column_int(stmt, index);
+ return (bool) (!!sqlite3_column_int(stmt, index));
}
-HAPI int db_begin_transaction(sqlite3 *db)
-{
- int ret = SQLITE_BUSY;
-
- while (1) {
- ret = sqlite3_exec(db, "BEGIN IMMEDIATE TRANSACTION", NULL, NULL, NULL);
- if (SQLITE_BUSY != ret) {
- break;
- }
- /* FIXME : we have to fix this sleep */
- sleep(1);
- }
-
- if (SQLITE_OK != ret) {
- _E("sqlite3_exec() Failed(%d)", ret);
- return APPL_ERROR_FAIL;
- }
-
- return APPL_ERROR_NONE;
-}
-
-
-
-HAPI int db_end_transaction(sqlite3 *db)
-{
- int ret = SQLITE_OK;
-
- while (1) {
- ret = sqlite3_exec(db, "COMMIT TRANSACTION", NULL, NULL, NULL);
- if (SQLITE_BUSY != ret) {
- break;
- }
- /* FIXME : we have to fix this sleep */
- sleep(1);
- }
-
- if (SQLITE_OK != ret) {
- _E("sqlite3_exec() Failed(%d)", ret);
- return APPL_ERROR_FAIL;
- }
-
- return APPL_ERROR_NONE;
-}
-
-
-
HAPI int db_create_table(sqlite3 *db)
{
const char *TABLES[] = {
-#include <Elementary.h>\r
-#include "main.h"\r
-#include "log.h"\r
-\r
-const char *const MAP_EDJE = "map.edj";\r
-\r
-Evas_Object *map_create(Evas_Object *parent)\r
-{\r
- Evas_Object *map = NULL;\r
- Evas_Object *button = NULL;\r
- char *path = NULL;\r
- char full_path[] = {0, };\r
-\r
- retv_if(!parent, NULL);\r
-\r
- path = app_get_resource_path();\r
- retv_if(!path, NULL);\r
-\r
- snprintf(full_path, sizeof(full_path), "%s/edje/%s", path, MAP_EDJE);\r
- free(path);\r
-\r
- map = elm_layout_add(parent);\r
- retv_if(!map, NULL);\r
- elm_layout_file_set(map, "main", NULL);\r
- evas_object_show(map);\r
-\r
- return map;\r
-}\r
-\r
-void map_destroy(Evas_Object *map)\r
-{\r
- Evas_Object *button = NULL;\r
-\r
- ret_if(!map);\r
-\r
- evas_object_del(map);\r
-}\r
+#include <Elementary.h>
+#include "main.h"
+#include "log.h"
+
+const char *const MAP_EDJE = "map.edj";
+
+
+static city_info_s cities[] = {
+ {
+ .id = CITY_HONOLULU,
+ .timezone = -10.0,
+ .name = "Honolulu",
+ .nation = "USA",
+ },
+ {
+ .id = CITY_LOS_ANGELES,
+ .timezone = -8.0,
+ .name = "Los Angeles",
+ .nation = "USA",
+ },
+ {
+ .id = CITY_SAN_FRANCISCO,
+ .timezone = -8.0,
+ .name = "San Francisco",
+ .nation = "USA",
+ },
+ {
+ .id = CITY_VANCOUVER,
+ .timezone = -8.0,
+ .name = "Vancouver",
+ .nation = "Canada",
+ },
+ {
+ .id = CITY_CHICAGO,
+ .timezone = -6.0,
+ .name = "Chicago",
+ .nation = "USA",
+ },
+ {
+ .id = CITY_MEICO_CITY,
+ .timezone = -6.0,
+ .name = "Mexico City",
+ .nation = "Mexico",
+ },
+ {
+ .id = CITY_SAN_JOSE,
+ .timezone = -6.0,
+ .name = "San Jose",
+ .nation = "Costa Rica",
+ },
+ {
+ .id = CITY_NEW_YORK_CITY,
+ .timezone = -5.0,
+ .name = "New York City",
+ .nation = "USA",
+ },
+ {
+ .id = CITY_TORONTO,
+ .timezone = -5.0,
+ .name = "Toronto",
+ .nation = "Canada",
+ },
+ {
+ .id = CITY_WASHINGTON_DC,
+ .timezone = -5.0,
+ .name = "Washington DC",
+ .nation = "USA",
+ },
+ {
+ .id = CITY_BRASILIA,
+ .timezone = -3.0,
+ .name = "Brasilia",
+ .nation = "Brazil",
+ },
+ {
+ .id = CITY_BUENOS_AIRES,
+ .timezone = -3.0,
+ .name = "Buenos Aires",
+ .nation = "Argentina",
+ },
+ {
+ .id = CITY_SAO_PAULO,
+ .timezone = -3.0,
+ .name = "Sao Paulo",
+ .nation = "Brazil",
+ },
+ {
+ .id = CITY_DUBLIN,
+ .timezone = 0.0,
+ .name = "Dublin",
+ .nation = "Ireland",
+ },
+ {
+ .id = CITY_LISBON,
+ .timezone = 0.0,
+ .name = "Lisbon",
+ .nation = "Portugal",
+ },
+ {
+ .id = CITY_LONDON,
+ .timezone = 0.0,
+ .name = "London",
+ .nation = "England",
+ },
+ {
+ .id = CITY_AMSTERDAM,
+ .timezone = 1.0,
+ .name = "Amsterdam",
+ .nation = "Netherlands",
+ },
+ {
+ .id = CITY_BARCELONA,
+ .timezone = 1.0,
+ .name = "Barcelona",
+ .nation = "Spain",
+ },
+ {
+ .id = CITY_BERLIN,
+ .timezone = 1.0,
+ .name = "Berlin",
+ .nation = "Germany",
+ },
+ {
+ .id = CITY_BRUSSELS,
+ .timezone = 1.0,
+ .name = "Brussels",
+ .nation = "Belgium",
+ },
+ {
+ .id = CITY_CAPE_TOWN,
+ .timezone = 1.0,
+ .name = "Cape Town",
+ .nation = "South Africa",
+ },
+ {
+ .id = CITY_GENEVA,
+ .timezone = 1.0,
+ .name = "Geneva",
+ .nation = "Switzerland",
+ },
+ {
+ .id = CITY_MADRID,
+ .timezone = 1.0,
+ .name = "Madrid",
+ .nation = "Spain",
+ },
+ {
+ .id = CITY_PARIS,
+ .timezone = 1.0,
+ .name = "Paris",
+ .nation = "France",
+ },
+ {
+ .id = CITY_ROME,
+ .timezone = 1.0,
+ .name = "Rome",
+ .nation = "Italy",
+ },
+ {
+ .id = CITY_STOCKHOLM,
+ .timezone = 1.0,
+ .name = "Stockholm",
+ .nation = "Sweden",
+ },
+ {
+ .id = CITY_WARSAW,
+ .timezone = 1.0,
+ .name = "Warsaw",
+ .nation = "Poland",
+ },
+ {
+ .id = CITY_ANKARA,
+ .timezone = 2.0,
+ .name = "Ankara",
+ .nation = "Turkey",
+ },
+ {
+ .id = CITY_ATHENS,
+ .timezone = 2.0,
+ .name = "Athens",
+ .nation = "Greece",
+ },
+ {
+ .id = CITY_HELSINKI,
+ .timezone = 2.0,
+ .name = "Helsinki",
+ .nation = "Finland",
+ },
+ {
+ .id = CITY_ISTANBUL,
+ .timezone = 2.0,
+ .name = "Istanbul",
+ .nation = "Turkey",
+ },
+ {
+ .id = CITY_JERUSALEM,
+ .timezone = 2.0,
+ .name = "Jerusalem",
+ .nation = "Israel",
+ },
+ {
+ .id = CITY_KAHIRA,
+ .timezone = 2.0,
+ .name = "Jerusalem",
+ .nation = "Egypt",
+ },
+ {
+ .id = CITY_BAGHDAD,
+ .timezone = 3.0,
+ .name = "Baghdad",
+ .nation = "Iraq",
+ },
+ {
+ .id = CITY_DUBAI,
+ .timezone = 3.0,
+ .name = "Dubai",
+ .nation = "United Arab Emirates",
+ },
+ {
+ .id = CITY_MOSCOW,
+ .timezone = 3.0,
+ .name = "Moscow",
+ .nation = "Russia",
+ },
+ {
+ .id = CITY_ISLAMABAD,
+ .timezone = 5.0,
+ .name = "Islamabad",
+ .nation = "Pakistan",
+ },
+ {
+ .id = CITY_DELHI,
+ .timezone = 5.5,
+ .name = "Delhi",
+ .nation = "India",
+ },
+ {
+ .id = CITY_MUMBAI,
+ .timezone = 5.5,
+ .name = "Mumbai",
+ .nation = "India",
+ },
+ {
+ .id = CITY_BOMBAY,
+ .timezone = 6.0,
+ .name = "Bombay",
+ .nation = "India",
+ },
+ {
+ .id = CITY_CALCUTTA,
+ .timezone = 6.0,
+ .name = "Calcutta",
+ .nation = "India",
+ },
+ {
+ .id = CITY_BANGKOK,
+ .timezone = 7.0,
+ .name = "Bangkok",
+ .nation = "Thailand",
+ },
+ {
+ .id = CITY_JAKARTA,
+ .timezone = 7.0,
+ .name = "Jakarta",
+ .nation = "Indonesia",
+ },
+ {
+ .id = CITY_BEIJING,
+ .timezone = 8.0,
+ .name = "Beijing",
+ .nation = "China",
+ },
+ {
+ .id = CITY_HONG_KONG,
+ .timezone = 8.0,
+ .name = "Hong Kong",
+ .nation = "China",
+ },
+ {
+ .id = CITY_SINGAPORE,
+ .timezone = 8.0,
+ .name = "Singapore",
+ .nation = "Singapore",
+ },
+ {
+ .id = CITY_TAIPEI,
+ .timezone = 8.0,
+ .name = "Taipei",
+ .nation = "Thaiwan",
+ },
+ {
+ .id = CITY_SEOUL,
+ .timezone = 9.0,
+ .name = "Seoul",
+ .nation = "Korea",
+ },
+ {
+ .id = CITY_TOKYO,
+ .timezone = 9.0,
+ .name = "Tokyo",
+ .nation = "Japan",
+ },
+ {
+ .id = CITY_SYDNEY,
+ .timezone = 10.0,
+ .name = "Sydney",
+ .nation = "Australia",
+ },
+};
+
+Evas_Object *map_create(Evas_Object *parent)
+{
+ Evas_Object *map = NULL;
+ Evas_Object *button = NULL;
+ char *path = NULL;
+ char full_path[] = {0, };
+
+ retv_if(!parent, NULL);
+
+ path = app_get_resource_path();
+ retv_if(!path, NULL);
+
+ snprintf(full_path, sizeof(full_path), "%s/edje/%s", path, MAP_EDJE);
+ free(path);
+
+ map = elm_layout_add(parent);
+ retv_if(!map, NULL);
+ elm_layout_file_set(map, "main", NULL);
+ evas_object_show(map);
+
+ return map;
+}
+
+void map_destroy(Evas_Object *map)
+{
+ Evas_Object *button = NULL;
+
+ ret_if(!map);
+
+ evas_object_del(map);
+}