void write_dc(struct tgl_dc *DC, void *extra)
{
int auth_file_fd = *(int *)extra;
- if (!DC) {
- int x = 0;
+ int x;
+
+ x = !!DC;
+
+ if (!x) {
assert(write(auth_file_fd, &x, 4) == 4);
return;
- } else {
- int x = 1;
- assert(write(auth_file_fd, &x, 4) == 4);
}
+ assert(write(auth_file_fd, &x, 4) == 4);
assert(DC->has_auth);
assert(write(auth_file_fd, &DC->port, 4) == 4);
int l = strlen(DC->ip);
if (binlog_enabled) {
return;
}
+
int auth_file_fd = open(get_auth_key_filename(), O_CREAT | O_RDWR, 0600);
+
assert(auth_file_fd >= 0);
int x = DC_SERIALIZED_MAGIC;
assert(write(auth_file_fd, &x, 4) == 4);
{
if (binlog_enabled)
return;
+
int secret_chat_fd = open(get_secret_chat_filename(), O_RDWR, 0600);
- if (secret_chat_fd < 0)
+
+ if (secret_chat_fd < 0) {
return;
+ }
//assert(secret_chat_fd >= 0);
int x;
if (read(secret_chat_fd, &x, 4) < 4) { close(secret_chat_fd); return; }
UC = tgl_peer_get(TLS, message->to_id);
struct tgl_user* buddy;
buddy = &(UC->user);
- char* phone = NULL;
+ char *phone = NULL;
if (buddy) {
phone = buddy->phone;
}
message->msg_state = TG_MESSAGE_STATE_READ;
- char* tb_name = get_table_name_from_number(message->to_id.id);
+ char *tb_name = get_table_name_from_number(message->to_id.id);
update_msg_into_db(message, tb_name, identifier);
if (message->media.type == tgl_message_media_photo) {
update_sent_media_info_in_db(message, (long long)message->media.photo.id);
void tg_type_notification(struct tgl_state *TLS, struct tgl_user* buddy, enum tgl_typing_status status)
{
- char* name_of_buddy = NULL;
+ char *name_of_buddy = NULL;
if (buddy->first_name && buddy->last_name) {
- name_of_buddy = (char*)malloc(strlen(buddy->first_name) + strlen(buddy->last_name) + 1);
+ name_of_buddy = (char *)malloc(strlen(buddy->first_name) + strlen(buddy->last_name) + 1);
strcpy(name_of_buddy, buddy->first_name);
strcat(name_of_buddy, buddy->last_name);
} else if(buddy->first_name) {
- name_of_buddy = (char*)malloc(strlen(buddy->first_name) + 1);
+ name_of_buddy = (char *)malloc(strlen(buddy->first_name) + 1);
strcpy(name_of_buddy, buddy->first_name);
} else {
- name_of_buddy = (char*)malloc(strlen(" ") + 1);
+ name_of_buddy = (char *)malloc(strlen(" ") + 1);
strcpy(name_of_buddy, " ");
}
#endif
}
+static inline void send_message(struct tgl_user *buddy, const char *str, const char *name_of_buddy, int name_of_buddy_len)
+{
+ char *update_msg;
+ int len;
+
+ /**
+ * "%s phone number updated" will be changed to IDS_STRING for i18n.
+ */
+ len = name_of_buddy_len + strlen(str);
+ update_msg = (char *)malloc(len + 1);
+ if (!update_msg) {
+ return;
+ }
+
+ snprintf(update_msg, len, str, name_of_buddy);
+ send_contact_updated_response(buddy->id.id, update_msg);
+ free(update_msg);
+}
+
void tg_user_update(struct tgl_state *TLS, struct tgl_user *buddy, unsigned flags)
{
- char* update_msg = NULL;
+ char *name_of_buddy;
+ int name_of_buddy_len;
+ static const char *NO_NAME = " ";
- char* name_of_buddy = NULL;
+ if (flags & TGL_UPDATE_CREATED) {
+ return;
+ }
if (buddy->first_name && buddy->last_name) {
- name_of_buddy = (char*)malloc(strlen(buddy->first_name) + strlen(buddy->last_name) + 1);
+ int first_len = strlen(buddy->first_name);
+ int last_len = strlen(buddy->last_name);
+
+ name_of_buddy_len = first_len + last_len;
+
+ name_of_buddy = (char *)malloc(name_of_buddy_len + 1);
+
strcpy(name_of_buddy, buddy->first_name);
- strcat(name_of_buddy, buddy->last_name);
+ strcpy(name_of_buddy + first_len, buddy->last_name);
} else if(buddy->first_name) {
- name_of_buddy = (char*)malloc(strlen(buddy->first_name) + 1);
- strcpy(name_of_buddy, buddy->first_name);
+ name_of_buddy = strdup(buddy->first_name);
+ name_of_buddy_len = strlen(name_of_buddy);
} else {
- name_of_buddy = (char*)malloc(strlen(" ") + 1);
- strcpy(name_of_buddy, " ");
+ name_of_buddy = NO_NAME;
+ name_of_buddy_len = strlen(NO_NAME);
}
- if (!(flags & TGL_UPDATE_CREATED)) {
- if (!(flags & TGL_UPDATE_DELETED)) {
-
- insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
-
- //mprintf (ev, " updated");
- if (flags & TGL_UPDATE_PHONE) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" phone number updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " phone number updated.");
- }
- if (flags & TGL_UPDATE_CONTACT) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" contact updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " contact updated.");
- }
- if (flags & TGL_UPDATE_PHOTO) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" photo updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " photo updated.");
-
- tgl_do_get_user_info(TLS, buddy->id, 0, &on_buddy_info_loaded, NULL);
- }
- if (flags & TGL_UPDATE_BLOCKED) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" contact blocked.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " contact blocked.");
- }
- if (flags & TGL_UPDATE_REAL_NAME) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" name updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " name updated.");
- }
- if (flags & TGL_UPDATE_NAME) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" contact name updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " contact name updated.");
- }
- if (flags & TGL_UPDATE_REQUESTED) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" status updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " status updated.");
- }
- if (flags & TGL_UPDATE_WORKING) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" status updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " status updated.");
- }
- if (flags & TGL_UPDATE_FLAGS) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" flags updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " flags updated.");
- }
- if (flags & TGL_UPDATE_TITLE) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" title updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " title updated.");
- }
- if (flags & TGL_UPDATE_ADMIN) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" admin updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " admin updated.");
- }
- if (flags & TGL_UPDATE_MEMBERS) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" members updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " members updated.");
- }
- if (flags & TGL_UPDATE_ACCESS_HASH) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" access hash updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " access hash updated.");
- }
- if (flags & TGL_UPDATE_USERNAME) {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" username updated.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " username updated.");
- }
- } else {
- update_msg = (char*)malloc(strlen(name_of_buddy) + strlen(" contact deleted.") + 1);
- strcpy(update_msg, name_of_buddy);
- strcat(update_msg, " contact deleted.");
- }
+ if (!name_of_buddy) {
+ /**
+ * @note
+ * Unable to allocate heap for buddy name
+ */
+ name_of_buddy = NO_NAME;
+ name_of_buddy_len = strlen(NO_NAME);
}
- if (update_msg) {
- // send message to application.
- send_contact_updated_response(buddy->id.id, update_msg);
+ if (!(flags & TGL_UPDATE_DELETED)) {
+ insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
- free(update_msg);
- update_msg = NULL;
+ if (flags & TGL_UPDATE_PHONE) {
+ send_message(buddy, "%s phone number updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_CONTACT) {
+ send_message(buddy, "%s contact updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_PHOTO) {
+ send_message(buddy, "%s photo updated.", name_of_buddy, name_of_buddy_len);
+ tgl_do_get_user_info(TLS, buddy->id, 0, &on_buddy_info_loaded, NULL);
+ }
+ if (flags & TGL_UPDATE_BLOCKED) {
+ send_message(buddy, "%s contact blocked.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_REAL_NAME) {
+ send_message(buddy, "%s name updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_NAME) {
+ send_message(buddy, "%s contact name updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_REQUESTED) {
+ send_message(buddy, "%s status updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_WORKING) {
+ send_message(buddy, "%s status updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_FLAGS) {
+ send_message(buddy, "%s flags updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_TITLE) {
+ send_message(buddy, "%s title updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_ADMIN) {
+ send_message(buddy, "%s admin updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_MEMBERS) {
+ send_message(buddy, "%s memgers updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_ACCESS_HASH) {
+ send_message(buddy, "%s access hash updated.", name_of_buddy, name_of_buddy_len);
+ }
+ if (flags & TGL_UPDATE_USERNAME) {
+ send_message(buddy, "%s username updated.", name_of_buddy, name_of_buddy_len);
+ }
+ } else {
+ send_message(buddy, "%s contact deleted.", name_of_buddy, name_of_buddy_len);
}
- if (name_of_buddy) {
+ if (name_of_buddy != NO_NAME) {
free(name_of_buddy);
name_of_buddy = NULL;
}
if (M->flags & (FLAG_MESSAGE_EMPTY | FLAG_DELETED)) {
return;
}
- if (!(M->flags & FLAG_CREATED)) {
+ if ((M->flags & FLAG_CREATED)) {
return;
}
if (M->service) {
}
-char* tg_create_print_name(struct tgl_state *TLS, tgl_peer_id_t id, const char *a1, const char *a2, const char *a3, const char *a4)
+char *tg_create_print_name(struct tgl_state *TLS, tgl_peer_id_t id, const char *a1, const char *a2, const char *a3, const char *a4)
{
return NULL;
}
if(tg_data->new_group_icon) {
- char* msg_table = get_table_name_from_number(chat_info->id.id);
+ char *msg_table = get_table_name_from_number(chat_info->id.id);
create_buddy_msg_table(msg_table);
- char* msg_data = "group icon changed.";
+ char *msg_data = "group icon changed.";
struct tgl_message msg;
msg.from_id.id = 0;
msg.from_id.type = 0;
return;
}
- char* msg_table = get_table_name_from_number(chat_info->id.id);
+ char *msg_table = get_table_name_from_number(chat_info->id.id);
create_buddy_msg_table(msg_table);
/*************** insert service message ********************/
- char* msg_data = "new group created.";
+ char *msg_data = "new group created.";
struct tgl_message msg;
msg.from_id.id = 0;
msg.from_id.type = 0;
{
for (int i = size - 1; i >= 0; i--) {
struct tgl_user *buddy = contacts[i];
- char* msg_table = get_table_name_from_number(buddy->id.id);
+ char *msg_table = get_table_name_from_number(buddy->id.id);
create_buddy_msg_table(msg_table);
free(msg_table);
case TGL_PEER_USER:
buddy = &(UC->user);
if (buddy) {
- char* msg_table = get_table_name_from_number(buddy->id.id);
+ char *msg_table = get_table_name_from_number(buddy->id.id);
create_buddy_msg_table(msg_table);
free(msg_table);
insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
int identifier = (int)callback_extra;
tgl_peer_t* UC = tgl_peer_get(TLS, message->to_id);
struct tgl_user* buddy = &(UC->user);
- char* phone = NULL;
+ char *phone = NULL;
if (buddy) {
phone = buddy->phone;
}
message->msg_state = TG_MESSAGE_STATE_FAILED;
}
- char* tb_name = get_table_name_from_number(message->to_id.id);
+ char *tb_name = get_table_name_from_number(message->to_id.id);
update_msg_into_db(message, tb_name, identifier);
if (message->media.type == tgl_message_media_photo) {
update_sent_media_info_in_db(message, (long long)identifier);
contact_data_s* contact = eina_list_nth(data->contact_list_to_add, data->current_index);
if (contact) {
- char* first_name = contact->first_name;
- char* last_name = contact->last_name;
- char* phone_number = contact->phone_number;
+ char *first_name = contact->first_name;
+ char *last_name = contact->last_name;
+ char *phone_number = contact->phone_number;
tgl_do_add_contact(TLS, phone_number, strlen(phone_number), first_name, strlen(first_name), last_name, strlen(last_name), 0, on_contact_added, data);
}
}
}
-void create_new_group(Eina_List* buddy_ids, const char* group_name, const char* group_icon)
+void create_new_group(Eina_List* buddy_ids, const char *group_name, const char *group_icon)
{
if (!buddy_ids || ! group_name) {
return;
static tgl_peer_id_t ids[1000];
int i;
for (i = 0; i < users_num; i++) {
- char* buddy_id_str = (char*)eina_list_nth(buddy_ids, i);
+ char *buddy_id_str = (char *)eina_list_nth(buddy_ids, i);
int buddy_id = atoi(buddy_id_str);
ids[i].id = buddy_id;
ids[i].type = TGL_PEER_USER;
if (eina_list_count(contact_list) > 0) {
contact_data_s* contact = eina_list_nth(contact_list, 0);
if (contact) {
- char* first_name = contact->first_name;
- char* last_name = contact->last_name;
- char* phone_number = contact->phone_number;
+ char *first_name = contact->first_name;
+ char *last_name = contact->last_name;
+ char *phone_number = contact->phone_number;
tg_data->current_index = 0;
tgl_do_add_contact(TLS, phone_number, strlen(phone_number) ,first_name, strlen(first_name), last_name, strlen(last_name), 0, on_contact_added, tg_data);
}
return;
} else {
- char* media_id_str = 0;
+ char *media_id_str = 0;
int media_type = 0;
- char* access_hash_str = 0;
+ char *access_hash_str = 0;
int user_id = 0;
int date = 0;
- char* caption = 0;
- char* longitude = 0;
- char* latitude = 0;
+ char *caption = 0;
+ char *longitude = 0;
+ char *latitude = 0;
int sizes = 0;
- char* phone_no = 0;
- char* first_name = 0;
- char* last_name = 0;
- char* file_path = 0;
+ char *phone_no = 0;
+ char *first_name = 0;
+ char *last_name = 0;
+ char *file_path = 0;
- char* photo_type1 = 0;
+ char *photo_type1 = 0;
int photo_loc_dc1 = 0;
- char* photo_loc_vol_str1 = 0;
+ char *photo_loc_vol_str1 = 0;
int photo_loc_id1 = 0;
- char* photo_loc_sec_str1 = 0;
+ char *photo_loc_sec_str1 = 0;
int photo_width1 = 0;
int photo_height1 = 0;
int photo_size1 = 0;
- char* photo_data1 = 0;
+ char *photo_data1 = 0;
- char* photo_type2 = 0;
+ char *photo_type2 = 0;
int photo_loc_dc2 = 0;
- char* photo_loc_vol_str2 = 0;
+ char *photo_loc_vol_str2 = 0;
int photo_loc_id2 = 0;
- char* photo_loc_sec_str2 = 0;
+ char *photo_loc_sec_str2 = 0;
int photo_width2 = 0;
int photo_height2 = 0;
int photo_size2 = 0;
- char* photo_data2 = 0;
+ char *photo_data2 = 0;
- char* photo_type3 = 0;
+ char *photo_type3 = 0;
int photo_loc_dc3 = 0;
- char* photo_loc_vol_str3 = 0;
+ char *photo_loc_vol_str3 = 0;
int photo_loc_id3 = 0;
- char* photo_loc_sec_str3 = 0;
+ char *photo_loc_sec_str3 = 0;
int photo_width3 = 0;
int photo_height3 = 0;
int photo_size3 = 0;
- char* photo_data3 = 0;
+ char *photo_data3 = 0;
- char* photo_type4 = 0;
+ char *photo_type4 = 0;
int photo_loc_dc4 = 0;
- char* photo_loc_vol_str4 = 0;
+ char *photo_loc_vol_str4 = 0;
int photo_loc_id4 = 0;
- char* photo_loc_sec_str4 = 0;
+ char *photo_loc_sec_str4 = 0;
int photo_width4 = 0;
int photo_height4 = 0;
int photo_size4 = 0;
- char* photo_data4 = 0;
+ char *photo_data4 = 0;
int row_count = eina_list_count(img_details);
for (int i = 0 ; i < row_count ; i++) {
Eina_List* row_vals = eina_list_nth(img_details, i);
- char* temp_media_id = (char*)eina_list_nth(row_vals, 0);
+ char *temp_media_id = (char *)eina_list_nth(row_vals, 0);
if(temp_media_id) {
media_id_str = strdup(temp_media_id);
free(temp_media_type);
}
- char* temp_access_hash = (char*)eina_list_nth(row_vals, 2);
+ char *temp_access_hash = (char *)eina_list_nth(row_vals, 2);
if(temp_access_hash) {
access_hash_str = strdup(temp_access_hash);
free(temp_date);
}
- char* temp_caption = (char*)eina_list_nth(row_vals, 5);
+ char *temp_caption = (char *)eina_list_nth(row_vals, 5);
if(temp_caption) {
caption = strdup(temp_caption);
free(temp_caption);
}
- char* temp_longitude = (char*)eina_list_nth(row_vals, 6);
+ char *temp_longitude = (char *)eina_list_nth(row_vals, 6);
if(temp_longitude) {
longitude = strdup(temp_longitude);
free(temp_longitude);
}
- char* temp_latitude = (char*)eina_list_nth(row_vals, 7);
+ char *temp_latitude = (char *)eina_list_nth(row_vals, 7);
if(temp_latitude) {
latitude = strdup(temp_latitude);
/***************************************************************/
- char* temp_photo_type1 = (char*)eina_list_nth(row_vals, 9);
+ char *temp_photo_type1 = (char *)eina_list_nth(row_vals, 9);
if (temp_photo_type1 && strlen(temp_photo_type1) > 0) {
photo_type1 =strdup(temp_photo_type1);
free(temp_photo_type1);
}
- char* temp_photo_loc_vol1 = (char*)eina_list_nth(row_vals, 11);
+ char *temp_photo_loc_vol1 = (char *)eina_list_nth(row_vals, 11);
if(temp_photo_loc_vol1 && strlen(temp_photo_loc_vol1) > 0) {
photo_loc_vol_str1 = strdup(temp_photo_loc_vol1);
free(temp_photo_loc_vol1);
free(temp_photo_loc_id1);
}
- char* temp_photo_loc_sec1 = (char*)eina_list_nth(row_vals, 13);
+ char *temp_photo_loc_sec1 = (char *)eina_list_nth(row_vals, 13);
if(temp_photo_loc_sec1 && strlen(temp_photo_loc_sec1) > 0) {
photo_loc_sec_str1 = strdup(temp_photo_loc_sec1);
free(temp_photo_loc_sec1);
}
- char* temp_photo_data1 = (char*)eina_list_nth(row_vals, 17);
+ char *temp_photo_data1 = (char *)eina_list_nth(row_vals, 17);
if(temp_photo_data1 && strlen(temp_photo_data1) > 0) {
photo_data1 = strdup(temp_photo_data1);
free(temp_photo_data1);
}
- char* temp_photo_type2 = (char*)eina_list_nth(row_vals, 18);
+ char *temp_photo_type2 = (char *)eina_list_nth(row_vals, 18);
if (temp_photo_type2 && strlen(temp_photo_type2) > 0) {
photo_type2 =strdup(temp_photo_type2);
free(temp_photo_type2);
}
- char* temp_photo_loc_vol2 = (char*)eina_list_nth(row_vals, 20);
+ char *temp_photo_loc_vol2 = (char *)eina_list_nth(row_vals, 20);
if(temp_photo_loc_vol2 && strlen(temp_photo_loc_vol2) > 0) {
photo_loc_vol_str2 = strdup(temp_photo_loc_vol2);
free(temp_photo_loc_vol2);
free(temp_photo_loc_id2);
}
- char* temp_photo_loc_sec2 = (char*)eina_list_nth(row_vals, 22);
+ char *temp_photo_loc_sec2 = (char *)eina_list_nth(row_vals, 22);
if(temp_photo_loc_sec2 && strlen(temp_photo_loc_sec2) > 0) {
photo_loc_sec_str2 = strdup(temp_photo_loc_sec2);
free(temp_photo_loc_sec2);
}
- char* temp_photo_data2 = (char*)eina_list_nth(row_vals, 26);
+ char *temp_photo_data2 = (char *)eina_list_nth(row_vals, 26);
if(temp_photo_data2 && strlen(temp_photo_data2) > 0) {
photo_data2 = strdup(temp_photo_data2);
free(temp_photo_data2);
}
- char* temp_photo_type3 = (char*)eina_list_nth(row_vals, 27);
+ char *temp_photo_type3 = (char *)eina_list_nth(row_vals, 27);
if (temp_photo_type3 && strlen(temp_photo_type3) > 0) {
photo_type3 =strdup(temp_photo_type3);
free(temp_photo_type3);
}
- char* temp_photo_loc_vol3 = (char*)eina_list_nth(row_vals, 29);
+ char *temp_photo_loc_vol3 = (char *)eina_list_nth(row_vals, 29);
if(temp_photo_loc_vol3 && strlen(temp_photo_loc_vol3) > 0) {
photo_loc_vol_str3 = strdup(temp_photo_loc_vol3);
free(temp_photo_loc_vol3);
free(temp_photo_loc_id3);
}
- char* temp_photo_loc_sec3 = (char*)eina_list_nth(row_vals, 31);
+ char *temp_photo_loc_sec3 = (char *)eina_list_nth(row_vals, 31);
if(temp_photo_loc_sec3 && strlen(temp_photo_loc_sec3) > 0) {
photo_loc_sec_str3 = strdup(temp_photo_loc_sec3);
free(temp_photo_loc_sec3);
}
- char* temp_photo_data3 = (char*)eina_list_nth(row_vals, 35);
+ char *temp_photo_data3 = (char *)eina_list_nth(row_vals, 35);
if(temp_photo_data3 && strlen(temp_photo_data3) > 0) {
photo_data3 = strdup(temp_photo_data3);
free(temp_photo_data3);
}
- char* temp_photo_type4 = (char*)eina_list_nth(row_vals, 36);
+ char *temp_photo_type4 = (char *)eina_list_nth(row_vals, 36);
if (temp_photo_type4 && strlen(temp_photo_type4) > 0) {
photo_type4 =strdup(temp_photo_type4);
free(temp_photo_type4);
}
- char* temp_photo_loc_vol4 = (char*)eina_list_nth(row_vals, 38);
+ char *temp_photo_loc_vol4 = (char *)eina_list_nth(row_vals, 38);
if(temp_photo_loc_vol4 && strlen(temp_photo_loc_vol4) > 0) {
photo_loc_vol_str4 = strdup(temp_photo_loc_vol4);
free(temp_photo_loc_vol4);
free(temp_photo_loc_id4);
}
- char* temp_photo_loc_sec4 = (char*)eina_list_nth(row_vals, 40);
+ char *temp_photo_loc_sec4 = (char *)eina_list_nth(row_vals, 40);
if(temp_photo_loc_sec4 && strlen(temp_photo_loc_sec4) > 0) {
photo_loc_sec_str4 = strdup(temp_photo_loc_sec4);
free(temp_photo_loc_sec4);
}
- char* temp_photo_data4 = (char*)eina_list_nth(row_vals, 44);
+ char *temp_photo_data4 = (char *)eina_list_nth(row_vals, 44);
if(temp_photo_data4 && strlen(temp_photo_data4) > 0) {
photo_data4 = strdup(temp_photo_data4);
free(temp_photo_data4);
/**************************************************************/
- char* temp_phone_no = (char*)eina_list_nth(row_vals, 45);
+ char *temp_phone_no = (char *)eina_list_nth(row_vals, 45);
if(temp_phone_no && strlen(temp_phone_no) > 0) {
phone_no = strdup(temp_phone_no);
free(temp_phone_no);
}
- char* temp_first_name = (char*)eina_list_nth(row_vals, 46);
+ char *temp_first_name = (char *)eina_list_nth(row_vals, 46);
if(temp_first_name && strlen(temp_first_name) > 0) {
first_name = strdup(temp_first_name);
free(temp_first_name);
}
- char* temp_last_name = (char*)eina_list_nth(row_vals, 47);
+ char *temp_last_name = (char *)eina_list_nth(row_vals, 47);
if(temp_last_name && strlen(temp_last_name) > 0) {
last_name = strdup(temp_last_name);
free(temp_last_name);
}
- char* temp_file_path = (char*)eina_list_nth(row_vals, 48);
+ char *temp_file_path = (char *)eina_list_nth(row_vals, 48);
if(temp_file_path && strlen(temp_file_path) > 0) {
file_path = strdup(temp_file_path);
#endif
}
-void send_message_to_buddy(int buddy_id, int message_id, int msg_type, char* msg_data, int type_of_chat)
+void send_message_to_buddy(int buddy_id, int message_id, int msg_type, char *msg_data, int type_of_chat)
{
// get type of chat from buddy_id.
- char* msg_table = get_table_name_from_number(buddy_id);
+ char *msg_table = get_table_name_from_number(buddy_id);
struct tgl_message* msg = get_message_from_message_table(message_id, msg_table);
if (msg) {
free(msg_table);
}
-void send_media_to_buddy(int buddy_id, int message_id, int media_id, int msg_type, char* file_path, int type_of_chat)
+void send_media_to_buddy(int buddy_id, int message_id, int media_id, int msg_type, char *file_path, int type_of_chat)
{
#if 0
int t = time(NULL);
msg.media.type = msg_type;
msg.media.photo.id = (long long)t;
- char* msg_table = get_table_name_from_number(buddy_id);
+ char *msg_table = get_table_name_from_number(buddy_id);
insert_msg_into_db(&msg, msg_table, t);
insert_media_info_to_db(&msg, file_path);
tgl_do_send_document(TLS, -1, msg.to_id, file_path, &on_message_sent_to_buddy, (void*) (t));
free(msg_table);
#else
- char* msg_table = get_table_name_from_number(buddy_id);
+ char *msg_table = get_table_name_from_number(buddy_id);
struct tgl_message* msg = get_message_from_message_table(message_id, msg_table);
if (msg) {
#endif
}
-static const char* _ui_utils_get_res_path()
+static const char *_ui_utils_get_res_path()
{
char res_folder_path[PATH_MAX] = {'\0'};
if (res_folder_path[0] == '\0') {
return res_folder_path;
}
-static char* ui_utils_get_resource(const char *res_name)
+static char *ui_utils_get_resource(const char *res_name)
{
static char res_path[PATH_MAX] = {'\0'};
snprintf(res_path, PATH_MAX, "%s%s", _ui_utils_get_res_path(), res_name);
//printf("libconfig not enabled\n");
}
- char* rsa_path = ui_utils_get_resource(DEFAULT_RSA_FILE_NAME);
+ char *rsa_path = ui_utils_get_resource(DEFAULT_RSA_FILE_NAME);
tasprintf(&rsa_file_name, "%s", rsa_path);
tasprintf(&config_full_path, "%s%s", DEFAULT_TELEGRAM_PATH, CONFIG_DIRECTORY);
struct stat st = {0};