summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJin Yoon <jinny.yoon@samsung.com>2015-08-05 14:15:11 +0900
committerJin Yoon <jinny.yoon@samsung.com>2015-08-05 14:15:11 +0900
commiteaab8abd261b3f3148e901f0111ed2d6ee75caf4 (patch)
treed1229a4c4632411dbc4dca784ee892691db74b8e
parent916f53fba9855765b91ce59d9c830c3e2609f719 (diff)
downloadadventure-eaab8abd261b3f3148e901f0111ed2d6ee75caf4.tar.gz
adventure-eaab8abd261b3f3148e901f0111ed2d6ee75caf4.tar.bz2
adventure-eaab8abd261b3f3148e901f0111ed2d6ee75caf4.zip
City : intial information
-rw-r--r--inc/map.h75
-rw-r--r--src/db.c63
-rw-r--r--src/map.c378
3 files changed, 419 insertions, 97 deletions
diff --git a/inc/map.h b/inc/map.h
index 52ecbc2..a5b4878 100644
--- a/inc/map.h
+++ b/inc/map.h
@@ -1,7 +1,68 @@
-#ifndef __MAP_H__
-#define __MAP_H__
-
-extern Evas_Object *map_create(Evas_Object *parent);
-extern void *map_destroy(Evas_Object *map);
-
-#endif /* __MAP_H__ */
+#ifndef __MAP_H__
+#define __MAP_H__
+
+enum {
+ CITY_HONOLULU = 0,
+ CITY_LOS_ANGELES,
+ CITY_SAN_FRANCISCO,
+ CITY_VANCOUVER,
+ CITY_CHICAGO,
+ CITY_MEICO_CITY,
+ CITY_SAN_JOSE,
+ CITY_NEW_YORK_CITY,
+ CITY_TORONTO,
+ CITY_WASHINGTON_DC,
+ CITY_BRASILIA,
+ CITY_BUENOS_AIRES,
+ CITY_SAO_PAULO,
+ CITY_DUBLIN,
+ CITY_LISBON,
+ CITY_LONDON,
+ CITY_AMSTERDAM,
+ CITY_BARCELONA,
+ CITY_BERLIN,
+ CITY_BRUSSELS,
+ CITY_CAPE_TOWN,
+ CITY_GENEVA,
+ CITY_MADRID,
+ CITY_PARIS,
+ CITY_ROME,
+ CITY_STOCKHOLM,
+ CITY_WARSAW,
+ CITY_ANKARA,
+ CITY_ATHENS,
+ CITY_HELSINKI,
+ CITY_ISTANBUL,
+ CITY_JERUSALEM,
+ CITY_KAHIRA,
+ CITY_BAGHDAD,
+ CITY_DUBAI,
+ CITY_MOSCOW,
+ CITY_ISLAMABAD,
+ CITY_DELHI,
+ CITY_MUMBAI,
+ CITY_BOMBAY,
+ CITY_CALCUTTA,
+ CITY_BANGKOK,
+ CITY_JAKARTA,
+ CITY_BEIJING,
+ CITY_HONG_KONG,
+ CITY_SINGAPORE,
+ CITY_TAIPEI,
+ CITY_SEOUL,
+ CITY_TOKYO,
+ CITY_SYDNEY,
+}
+
+struct _city_info_s {
+ int id;
+ float timezone;
+ char *name;
+ char *nation;
+};
+typedef struct _city_info_s city_info_s;
+
+extern Evas_Object *map_create(Evas_Object *parent);
+extern void *map_destroy(Evas_Object *map);
+
+#endif /* __MAP_H__ */
diff --git a/src/db.c b/src/db.c
index 74ca5ab..504421c 100644
--- a/src/db.c
+++ b/src/db.c
@@ -43,15 +43,14 @@ HAPI sqlite3 *db_open(void)
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;
}
@@ -91,9 +90,9 @@ HAPI int db_next(sqlite3 *db, sqlite3_stmt *stmt)
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));
@@ -180,9 +179,13 @@ HAPI int db_bind_str(sqlite3 *db, sqlite3_stmt *stmt, int idx, const char *str)
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;
@@ -196,7 +199,7 @@ HAPI int db_bind_str(sqlite3 *db, sqlite3_stmt *stmt, int idx, const char *str)
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));
}
@@ -263,52 +266,6 @@ ERROR:
-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[] = {
diff --git a/src/map.c b/src/map.c
index c5ce96a..167dbd1 100644
--- a/src/map.c
+++ b/src/map.c
@@ -1,37 +1,341 @@
-#include <Elementary.h>
-#include "main.h"
-#include "log.h"
-
-const char *const MAP_EDJE = "map.edj";
-
-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);
-}
+#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);
+}