static void _insert_contacts_add_number_callback(const char *number, void *data) { char *content; struct MessageNewViewData *view; int len; view = (struct MessageNewViewData *)data; content = elm_entry_markup_to_utf8(elm_entry_entry_get(view->content_entry)); len = phone_utils_gsm_sms_strlen(content); // Make space for text, number and ending null character content = realloc(content, len + strlen(number) + 1); // Add the number to the end of the content sprintf(content + len, "%s ", number); if (view->content) { free(view->content); } view->content = content; if (view->content != NULL) { elm_entry_entry_set(view->content_entry, elm_entry_utf8_to_markup(view->content)); } }
SH_API void entry_callback(void *data, Evas_Object *obj, void *event_info) { Evas_Object *entry = data; if (elm_entry_entry_get(entry)) { char *s; s = elm_entry_markup_to_utf8(elm_entry_entry_get(entry)); printf(s); E_FREE(s); } elm_exit(); }
static void frame_content_continue_clicked(struct MessageNewViewData *data, Evas_Object * obj, void *event_info) { char *content = g_strstrip(elm_entry_markup_to_utf8 (elm_entry_entry_get(data->entry))); if (strlen(content) == 0) { //TODO: display notify about sending blank message } data->mode = MODE_RECIPIENT; window_frame_show(data->win, data, frame_recipient_show, frame_recipient_hide); free(content); }
static void frame_content_hide(struct MessageNewViewData *data) { struct Window *win = data->win; // Save content data->content = g_strstrip(elm_entry_markup_to_utf8 (elm_entry_entry_get(data->entry))); // Free objects evas_object_del(data->bt1); evas_object_del(data->bt2); evas_object_del(data->entry); evas_object_del(data->sc); window_kbd_hide(win); }
static void on_edit(void *data, Evas_Object *obj, void *event_info) { const char *text; char buf[256], *text2; int len; text = elm_entry_entry_get(sms_entry); if (!text) return; text2 = elm_entry_markup_to_utf8(text); if (!text2) return; len = strlen(text2); if (len > 0) { if (text2[len - 1] == '\n') text2[len - 1] = 0; } len = strlen(text2); free(text2); snprintf(buf, sizeof(buf), "%i", len); elm_label_label_set(write_stat, buf); }
static void _forward_clicked(void *_data, Evas_Object * obj, void *event_info) { (void) obj; (void) event_info; char *content; GHashTable *options; struct MessageShowViewData *view = (struct MessageShowViewData *) _data; evas_object_hide(view->hv); options = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, common_utils_variant_unref); content = elm_entry_markup_to_utf8(elm_object_text_get(view->content)); if (content) { g_hash_table_insert(options, "Content", g_variant_ref_sink(g_variant_new_string(content))); free(content); } phoneui_messages_message_new(options); }
static void on_send(void *data, Evas_Object *obj, void *event_info) { const char *text; char *text2; int len; if (!number) { alert("No recipient indicated.<br>" "Please specify one"); return; } text = elm_entry_entry_get(sms_entry); if (!text) { alert("The message text is<br>" "empty. Cannot send"); return; } text2 = elm_entry_markup_to_utf8(text); if (!text2) { alert("Conversion from entry<br>" "to UTF8 failed"); return; } len = strlen(text2); if (len > 0) { if (text2[len - 1] == '\n') text2[len - 1] = 0; } printf("TO: <%s>\n", number); printf("%s\n", text2); // FIXME: no reply handler in efso to track message send // FIXME: text input is utf8 - but encoding unspecified - efso probably // should allow for encoding params or convert to a proper encoding // (gsm, ucs2 etc.) for you. if (data_message_sent_store(reply_to, number, text2)) { #ifdef HAVE_EFSO efso_gsm_sms_send_message(number, text2, NULL, NULL); #elif HAVE_EOFONO E_Ofono_Element *element; Eina_Array *modems = NULL; const char *path; Eina_Bool powered = 0; if (e_ofono_manager_get()) { fputs("DBG: Trying to get modem from oFono\n", stderr); if (e_ofono_manager_modems_get(&modems) && (modems) && (modems->count > 0)) { path = eina_array_data_get(modems, 0); fprintf(stderr, "DBG: Using oFono modem %s\n", path); element = e_ofono_element_get(path, "org.ofono.Modem"); if (e_ofono_modem_powered_get(element, &powered)) { if (powered) { element = e_ofono_element_get (path, "org.ofono.SmsManager"); if (!e_ofono_sms_send_message (element, number, text2, NULL, NULL)) { alert("oFono error!<br>" "Check log for more info.<br>" "(message not sent)"); fputs ("ERROR: sms_send failed\n", stderr); return; } } else { alert("Modem powered off<br>" "(message not sent)"); return; } } else { alert("oFono error!<br>" "Check log for more info.<br>" "(message not sent)"); fputs("ERROR: modem_powered_get failed\n", stderr); return; } } } else { alert("ofonod is not running!<br>" "(message not sent)"); return; } #endif } else { alert("Cannot store sent message.<br>" "FIXME: select msg to delete"); free(text2); return; } free(text2); on_write(NULL, NULL, NULL); }
char *common_utils_entry_layout_get_text(Evas_Object *layout) { Evas_Object *entry = elm_object_part_content_get(layout, "elm.swallow.content"); return elm_entry_markup_to_utf8(elm_entry_entry_get(entry)); }
static void _content_changed(void *_data, Evas_Object * obj, void *event_info) { (void) event_info; struct MessageNewViewData *view = (struct MessageNewViewData *) _data; GRegex *rgx; char *content; int limit; /* the limit of the sms */ int len; /* the number of characters in the sms */ char text[64]; /*FIXME: consider changing to an iterative way by using get_size (emulating what's * being done in phone_utils) as calculating for all the string on every keystroke is a bit sluggish. */ content = elm_entry_markup_to_utf8(elm_entry_entry_get(obj)); /* if the entry is still empty elm_entry_markup_to_utf8 will return * NULL - which makes g_strstrip segfault :| * and we don't have to do all the fancy calculation * if it is empty */ if (!content) { sprintf(text, D_("%d characters left [%d]"), PHONE_UTILS_GSM_SMS_TEXT_LIMIT, PHONE_UTILS_GSM_SMS_TEXT_LIMIT); edje_object_part_text_set(elm_layout_edje_get (view->layout_content), "characters_left", text); return; } /* Elementary uses the <ps> tag as paragraph separator, this get converted to * the Unicode paragraph separator "\xE2\x80\xA9" causing the sms to grow in size; * let's replace it with the standard "\n" separator avoiding to send multiple * SMSs messages */ char *tmp = content; rgx = g_regex_new("\xE2\x80\xA9", 0, 0, NULL); content = g_regex_replace_literal(rgx, tmp, -1, 0, "\n", 0, NULL); g_regex_unref(rgx); free(tmp); len = phone_utils_gsm_sms_strlen(content); /* if it includes chars that can't be represented * with 7bit encoding, this sms will be sent as ucs-2 treat * it this way! */ if (phone_utils_gsm_is_ucs(content)) { limit = PHONE_UTILS_GSM_SMS_UCS_LIMIT; /* ucs-2 number of chars limit */ if (len > limit) { limit = PHONE_UTILS_GSM_SMS_UCS_SPLIT_LIMIT; } } else { limit = PHONE_UTILS_GSM_SMS_TEXT_LIMIT; /* regular number of chars limit */ if (len > limit) { limit = PHONE_UTILS_GSM_SMS_TEXT_SPLIT_LIMIT; } } int left = limit - (len % limit); int msg_count = (len / limit) + 1; if (left == limit && (len / limit) + 1 > 1) { left = 0; msg_count--; } /*FIXME: BAD! will cause a string-cut when using a long translation!!! */ snprintf(text, sizeof(text), D_("%d characters left [%d]"), left, msg_count); ui_utils_view_text_set(VIEW_PTR(*view), "characters_left", text); edje_object_part_text_set(elm_layout_edje_get(view->layout_content), "characters_left", text); if (view->content) { free(view->content); } view->content = content; }
Eina_Bool Add_To_Most_Visited_Sites_View::_save_button_clicked(void) { BROWSER_LOGD("[%s]", __func__); Evas_Object *entry = br_elm_editfield_entry_get(m_url_edit_field); char* url = _trim(elm_entry_markup_to_utf8(elm_entry_entry_get(entry))); if (!url || !strlen(url)) { show_msg_popup(BR_STRING_EMPTY); return EINA_FALSE; } std::string full_url = std::string(url); if (_has_url_sheme(url)) { char *token = strstr(url, BROWSER_URL_SCHEME_CHECK); if (token && strlen(token) == 3) { /* If input url has only sheme such as 'http://', 'https://' */ show_msg_popup(BR_STRING_EMPTY); return EINA_FALSE; } } else full_url = std::string(BROWSER_HTTP_SCHEME) + std::string(url); if (m_most_visited_sites->m_selected_item->url && strlen(m_most_visited_sites->m_selected_item->url)) { if (!strcmp(full_url.c_str(), m_most_visited_sites->m_selected_item->url)) { /* If the url is not changed in case of modify speed dial item. */ if (elm_naviframe_bottom_item_get(m_navi_bar) != elm_naviframe_top_item_get(m_navi_bar)) elm_naviframe_item_pop(m_navi_bar); return EINA_FALSE; } } std::string history_id; history_id = m_most_visited_sites->m_most_visited_sites_db->get_history_id_by_url(full_url.c_str()); char *screen_shot_path = NULL; if (history_id.empty()) screen_shot_path = strdup("default_noscreenshot"); else screen_shot_path = strdup(history_id.c_str()); if (!screen_shot_path) { BROWSER_LOGE("strdup failed"); return EINA_FALSE; } int index = 0; Elm_Object_Item *it = elm_gengrid_first_item_get(m_most_visited_sites->m_gengrid); do { if (it == m_most_visited_sites->m_selected_item->item) break; index++; } while (it = elm_gengrid_item_next_get(it)); if (!m_most_visited_sites->m_most_visited_sites_db->save_most_visited_sites_item(index, full_url.c_str(), full_url.c_str(), screen_shot_path)) { BROWSER_LOGE("save_most_visited_sites_item failed"); return EINA_FALSE; } free(screen_shot_path); if (!m_most_visited_sites->_reload_items()) { BROWSER_LOGE("m_most_visited_sites->_reload_items failed"); return EINA_FALSE; } return EINA_TRUE; }