bool MCSystemPickMedia(MCMediaType p_types, bool p_multiple, MCStringRef& r_result) { s_media_status = kMCAndroidMediaWaiting; bool t_audio, t_video; t_audio = (kMCMediaTypeAnyAudio & p_types) != 0; t_video = (kMCMediaTypeAnyVideo & p_types) != 0; if (t_audio && !t_video) { MCAndroidEngineCall("pickMedia", "vs", nil, "audio/*"); } else if (!t_audio && t_video) { MCAndroidEngineCall("pickMedia", "vs", nil, "video/*"); } else { MCAndroidEngineCall("pickMedia", "vs", nil, "audio/* video/*"); } while (s_media_status == kMCAndroidMediaWaiting) MCscreen->wait(60.0, False, True); /* UNCHECKED */ MCStringCopy(s_media_content, r_result); // MCLog("Media Types Returned: %s", s_media_content); }
bool MCSystemPlaySound(const char *p_file, bool p_looping) { //MCLog("MCSystemPlaySound(%s, %s)", p_file, p_looping?"true":"false"); bool t_success; if (s_sound_file != nil) { MCCStringFree(s_sound_file); s_sound_file = nil; } s_sound_file = MCS_resolvepath(p_file); const char *t_apk_file = nil; if (path_to_apk_path(s_sound_file, t_apk_file)) MCAndroidEngineCall("playSound", "bsbb", &t_success, t_apk_file, true, p_looping); else MCAndroidEngineCall("playSound", "bsbb", &t_success, s_sound_file, false, p_looping); if (!t_success) { MCCStringFree(s_sound_file); s_sound_file = nil; } return t_success; }
bool MCSystemLoadUrl(const char *p_url, MCSystemUrlCallback p_callback, void *p_context) { bool t_success = true; MCUrlInfo *t_info = nil; t_success = storeURLInfo(p_url, p_callback, p_context, t_info); if (t_success) { MCAndroidEngineCall("setURLTimeout", "vi", nil, (int32_t)MCsockettimeout); MCAndroidEngineCall("loadURL", "biss", &t_success, t_info->id, p_url, MChttpheaders); } return t_success; }
static MCAndroidDisplayFormat android_get_display_format() { int32_t t_display_format = 0; MCAndroidEngineCall("getDisplayOrientation", "i", &t_display_format); // MCLog("getDisplayOrientation() == %d", t_display_format); return (MCAndroidDisplayFormat)t_display_format; }
static int android_get_display_rotation() { int32_t t_display_rotation = 0; MCAndroidEngineCall("getDisplayRotation", "i", &t_display_rotation); // MCLog("getDisplayRotation() == %d", t_display_rotation); return t_display_rotation; }
bool MCSystemPostUrl(const char *p_url, const void *p_data, uint32_t p_length, MCSystemUrlCallback p_callback, void *p_context) { bool t_success = true; MCUrlInfo *t_info = nil; t_success = storeURLInfo(p_url, p_callback, p_context, t_info); if (t_success) { MCString t_data((const char*)p_data, p_length); MCAndroidEngineCall("setURLTimeout", "vi", nil, (int32_t)MCsockettimeout); MCAndroidEngineCall("postURL", "bissd", &t_success, t_info->id, p_url, MChttpheaders, &t_data); } return t_success; }
static int android_get_device_rotation() { int32_t t_dev_rotation = 0; MCAndroidEngineCall("getDeviceRotation", "i", &t_dev_rotation); // MCLog("getDeviceRotation() == %d", t_dev_rotation); return t_dev_rotation; }
bool MCSystemGetPlayLoudness(uint2& r_loudness) { int32_t t_loudness; MCAndroidEngineCall("getPlayLoudness", "i", &t_loudness); r_loudness = t_loudness; return true; }
// IM-2013-04-17: [[ AdModule ]] call out to Engine method to load AdModule class bool MCAndroidInneractiveAdInitModule() { if (s_admodule != nil) return true; MCAndroidEngineCall("loadAdModule", "o", &s_admodule); return s_admodule != nil; }
bool MCAndroidSystem::GetVersion(MCStringRef& r_string) { MCAndroidEngineCall("getSystemVersion", "x", &r_string); return true; }
bool MCCanSendMail() { bool t_can_send = false; MCAndroidEngineCall("canSendMail", "b", &t_can_send); return t_can_send; }
bool MCAndroidSystem::GetMachine(MCStringRef& r_string) { MCAndroidEngineCall("getMachine", "x", &r_string); return true; }
bool MCSystemSetPlayLoudness(uint2 p_loudness) { bool t_success; MCAndroidEngineCall("setPlayLoudness", "bi", &t_success, p_loudness); return t_success; }
// MW-2013-10-02: [[ MobileSSLVerify ]] Enable or disable SSL verification. void MCSystemSetUrlSSLVerification(bool enabled) { MCAndroidEngineCall("setURLSSLVerification", "vb", nil, enabled); }
bool MCSystemLaunchUrl(const char *p_url) { MCAndroidEngineCall("launchUrl", "vs", nil, p_url); return true; }
static void android_set_display_orientation(MCAndroidDisplayOrientation p_orientation) { // MCLog("setDisplayOrientation(%d)", p_orientation); MCAndroidEngineCall("setDisplayOrientation", "vi", nil, (int)p_orientation); }
Exec_stat MCHandleComposeMail(MCMailType p_type, MCParameter *p_parameters) { bool t_success; t_success = true; char *t_to, *t_cc, *t_bcc; MCString t_subject, t_body; MCVariableValue *t_attachments; t_to = t_cc = t_bcc = nil; t_attachments = nil; if (t_success) t_success = MCParseParameters(p_parameters, "|dsssda", &t_subject, &t_to, &t_cc, &t_bcc, &t_body, &t_attachments); if (t_success) { //MCLog("mail type: %d", p_type); //MCLog("subject: %d: \"%s\"", t_subject.getlength(), t_subject.getstring()); //MCLog("body: %d: \"%s\"", t_body.getlength(), t_body.getstring()); const char *t_prep_sig; if (p_type == kMCMailTypeUnicode) t_prep_sig = "vsssUUb"; else t_prep_sig = "vsssSSb"; MCAndroidEngineCall("prepareEmail", t_prep_sig, nil, t_to, t_cc, t_bcc, &t_subject, &t_body, p_type == kMCMailTypeHtml); // add attachments if (t_attachments != nil) { MCVariableArray *t_array; t_array = t_attachments -> get_array(); if (t_array -> isnumeric()) { for(uint32_t i = 0; i < t_array -> getnfilled(); i++) { MCHashentry *t_entry; t_entry = t_array -> lookupindex(i + 1, False); if (t_entry == nil) continue; if (!t_entry -> value . is_array()) continue; MCString t_data; MCString t_file; MCString t_type; MCString t_name; if (array_to_attachment(t_entry -> value . get_array(), t_data, t_file, t_type, t_name)) { //MCLog("file: %p: %d: \"%s\"", &t_file, t_file.getlength(), t_file.getstring() != nil ? t_file.getstring() : "NULL"); //MCLog("data: %p: %d: \"...\"", &t_data, t_data.getlength()); //MCLog("type: %p: %d: \"%s\"", &t_type, t_type.getlength(), t_type.getstring() != nil ? t_type.getstring() : "NULL"); //MCLog("name: %p: %d: \"%s\"", &t_name, t_name.getlength(), t_name.getstring() != nil ? t_name.getstring() : "NULL"); if (t_file.getlength() > 0) MCAndroidEngineCall("addAttachment", "vSSS", nil, &t_file, &t_type, &t_name); else MCAndroidEngineCall("addAttachment", "vdSS", nil, &t_data, &t_type, &t_name); } } } else { MCString t_data; MCString t_file; MCString t_type; MCString t_name; if (array_to_attachment(t_array, t_data, t_file, t_type, t_name)) { if (t_file.getlength() > 0) MCAndroidEngineCall("addAttachment", "vSSS", nil, &t_file, &t_type, &t_name); else MCAndroidEngineCall("addAttachment", "vdSS", nil, &t_data, &t_type, &t_name); } } } MCAndroidEngineCall("sendEmail", "v", nil); } while (s_mail_status == kMCAndroidMailWaiting) MCscreen->wait(60.0, False, True); switch (s_mail_status) { case kMCAndroidMailSent: MCresult -> sets("sent"); break; case kMCAndroidMailCanceled: MCresult -> sets("cancel"); break; case kMCAndroidMailUnknown: default: MCresult -> sets("unknown"); break; } delete t_subject . getstring(); MCCStringFree(t_to); MCCStringFree(t_cc); MCCStringFree(t_bcc); delete t_body . getstring(); return ES_NORMAL; }
// Parse the fonts folder (as set up by the standalone builder), locating any font files. // For each font file found, attempt to parse using freetype and if successful, add to the custom font list. // If particularly intensive, the parsing step could be moved to the IDE, which would just generate the required meta-data. void MCAndroidCustomFontsLoad() { bool t_success; t_success = true; FT_Library t_ft_library; t_ft_library = nil; if (t_success) t_success = FT_Init_FreeType(&t_ft_library) == 0; char *t_file_list; t_file_list = nil; if (t_success) { MCAndroidEngineCall("getAssetFolderEntryList", "ss", &t_file_list, s_font_folder); t_success = t_file_list != nil; } char *t_next_entry; t_next_entry = t_file_list; MCAndroidCustomFont *t_last_font; t_last_font = s_custom_fonts; while (t_success && *t_next_entry != '\0') { char *t_file_name; t_file_name = nil; char *t_file_name_end; t_file_name_end = nil; if (t_success) { t_file_name = t_next_entry; t_file_name_end = strchr(t_file_name, '\n'); t_success = t_file_name_end != nil; } char *t_folder; t_folder = nil; if (t_success) { *t_file_name_end = '\0'; t_folder = strchr(t_file_name_end + 1, ','); t_success = t_folder != nil; } char *t_folder_end; t_folder_end = nil; if (t_success) { t_folder++; t_folder_end = strchr(t_folder, '\n'); if (t_folder_end == nil) t_folder_end = strchr(t_folder, '\0'); t_success = t_folder_end != nil; } Boolean t_is_folder; t_is_folder = false; if (t_success) { if (*t_folder_end != '\0') *t_folder_end++ = '\0'; t_success = MCU_stob(t_folder, t_is_folder); } if (t_success) if (!t_is_folder) { MCAndroidCustomFont *t_font; t_font = nil; if (create_custom_font_from_path(t_file_name, t_ft_library, t_font)) { if (t_last_font == nil) s_custom_fonts = t_font; else t_last_font->next = t_font; t_last_font = t_font; } } t_next_entry = t_folder_end; } if (t_ft_library != nil) FT_Done_FreeType(t_ft_library); }
void MCAndroidSendEmail(const char *p_address, const char *p_cc_address, const char *p_subject, const char *p_message_body) { MCAndroidEngineCall("sendEmail", "vssss", nil, p_address, p_cc_address, p_subject, p_message_body); }
bool MCSystemCanSendTextMessage() { bool t_can_send = false; MCAndroidEngineCall("canSendTextMessage", "b", &t_can_send); return t_can_send; }