}
char* err_msg = 0;
- char *query_format = "CREATE INDEX tg_index_%s ON %s (%s);";
+ char *query_format = "CREATE INDEX tg_index_%s_%s ON %s (%s);";
char *query_string = NULL;
int query_length = strlen(query_format) + strlen(table_name) + (strlen(column_name) * 2) + 20;
int ret;
return EINA_FALSE;
}
- snprintf(query_string, query_length, query_format, column_name, table_name, column_name);
+ snprintf(query_string, query_length, query_format, table_name, column_name, table_name, column_name);
sqlite3* db = create_database(DEFAULT_TG_DATABASE_PATH);
if (!table_name) {
return EINA_FALSE;
}
- sqlite3* db = create_database(DEFAULT_TG_DATABASE_PATH);
- /*****No rows identification*****/
- char* row_cnt_qry = (char*)malloc(strlen("SELECT COUNT(*) FROM ") + strlen(table_name) + strlen(";") +1);
- strcpy(row_cnt_qry, "SELECT COUNT(*) FROM ");
- strcat(row_cnt_qry, table_name);
- strcat(row_cnt_qry, ";");
-
- int no_of_rows = 0;
- //ret = sqlite3_exec(s_info.db,var_query, callback,(void*)s_info.db, &err_msg);
-
- sqlite3_stmt *stmt;
- if (sqlite3_prepare_v2(db, row_cnt_qry, -1, &stmt, NULL) == SQLITE_OK) {
- if (sqlite3_step(stmt) == SQLITE_ERROR) {
- no_of_rows = 0;
- } else {
- no_of_rows = sqlite3_column_int(stmt, 0);
- }
- sqlite3_finalize(stmt);
- }
- close_database(db);
- free(row_cnt_qry);
- if(no_of_rows <= 0) {
- return EINA_FALSE;
+ /*****No rows identification*****/
+ if (get_number_of_rows(table_name, NULL) == 0) {
+ DBG("There are no rows on [%s]", table_name);
+ return NULL;
}
/********************************/
- db = create_database(DEFAULT_TG_DATABASE_PATH);
+ sqlite3* db = create_database(DEFAULT_TG_DATABASE_PATH);
int ret = 0 ;
char* err_msg = 0;
//int col_count = eina_list_count(column_names);
Evas_Object* chat_scroller = data;
appdata_s* ad = evas_object_data_get(chat_scroller, "app_data");
int user_id = (int)evas_object_data_get(chat_scroller, "user_id");
- int message_id = (int)evas_object_data_get(chat_scroller, "message_id");
+ int message_id = (int)evas_object_data_get(entry, "message_id");
peer_with_pic_s *sel_item = eina_list_nth(ad->peer_list, user_id);
int buddy_id = sel_item->use_data->peer_id;
if (data == NULL) {
ERR("Invalid Parameter.");
+ return NULL;
}
char edj_path[PATH_MAX] = {0, };
return layout;
}
- evas_object_data_set(entry, "chat_list", (void*)chat_scroller);
- evas_object_data_set(entry, "message_id", (void*)msg->msg_id);
if (msg->media_type != tgl_message_media_none) {
entry = elm_entry_add(obj);
} else {
entry = elm_label_add(obj);
}
+
+ evas_object_data_set(entry, "message_id", (void*)msg->msg_id);
+ evas_object_data_set(entry, "chat_list", (void*)chat_scroller);
+
layout = elm_layout_add(obj);
if (msg->out) {
Evas_Object* chat_scroller = evas_object_data_get(ad->nf, "chat_list");
Evas_Object *message = NULL;
- if (msg) {
- // update peer table
- if (peer_item) {
- peer_item->last_msg_id = msg->msg_id;
- peer_item->last_msg_date = msg->date;
- insert_or_update_peer_into_database(peer_item);
- }
+ if (msg == NULL) {
+ ERR("msg not found");
+ return;
+ }
- Evas_Object *layout = evas_object_data_get(ad->nf, "main_layout");
- if (layout) {
- int is_end_edge = (int) evas_object_data_get(layout, "is_end_edge");
- if (!is_end_edge) {
- Evas_Object *bubble_layout = NULL;
- bubble_layout = elm_object_part_content_get(layout, "swallow.messagebubble");
+ // update peer table
+ if (peer_item) {
+ peer_item->last_msg_id = msg->msg_id;
+ peer_item->last_msg_date = msg->date;
+ insert_or_update_peer_into_database(peer_item);
+ }
- int user_id = (int) evas_object_data_get(chat_scroller, "user_id");
- peer_with_pic_s *sel_item = eina_list_nth(ad->peer_list, user_id);
- char *sender_name = NULL;
- if (sel_item->use_data->peer_type == TGL_PEER_USER) {
- sender_name = replace(sel_item->use_data->print_name, '_', " ");
- } else if (sel_item->use_data->peer_type == TGL_PEER_CHAT) {
- int from_id = msg->from_id;
- // get name of buddy
- char* buddy_name = get_buddy_name_from_id(from_id);
- if (buddy_name) {
- sender_name = replace(buddy_name, '_', " ");
- free(buddy_name);
- }
- } else {
- sender_name = replace(sel_item->use_data->print_name, '_', " ");
+ Evas_Object *layout = evas_object_data_get(ad->nf, "main_layout");
+ if (layout) {
+ int is_end_edge = (int) evas_object_data_get(layout, "is_end_edge");
+ if (!is_end_edge) {
+ Evas_Object *bubble_layout = NULL;
+ bubble_layout = elm_object_part_content_get(layout, "swallow.messagebubble");
+
+ int user_id = (int) evas_object_data_get(chat_scroller, "user_id");
+ peer_with_pic_s *sel_item = eina_list_nth(ad->peer_list, user_id);
+ char *sender_name = NULL;
+ if (sel_item->use_data->peer_type == TGL_PEER_USER) {
+ sender_name = replace(sel_item->use_data->print_name, '_', " ");
+ } else if (sel_item->use_data->peer_type == TGL_PEER_CHAT) {
+ int from_id = msg->from_id;
+ // get name of buddy
+ char* buddy_name = get_buddy_name_from_id(from_id);
+ if (buddy_name) {
+ sender_name = replace(buddy_name, '_', " ");
+ free(buddy_name);
}
-
- elm_object_part_text_set(bubble_layout, "text_name", sender_name);
- elm_object_part_text_set(bubble_layout, "text_message", msg->message);
- elm_object_signal_emit(layout, "show", "bubblemessage");
+ } else {
+ sender_name = replace(sel_item->use_data->print_name, '_', " ");
}
+
+ elm_object_part_text_set(bubble_layout, "text_name", sender_name);
+ elm_object_part_text_set(bubble_layout, "text_message", msg->message);
+ elm_object_signal_emit(layout, "show", "bubblemessage");
}
}
+
free(tablename);
message = on_message_item_content_get_cb((void *)msg, chat_scroller, "elm.icon.entry");