static void testMessageParser(mailcore::Data * data) { mailcore::MessageParser * parser = mailcore::MessageParser::messageParserWithData(data); MCLog("%s", MCUTF8DESC(parser)); MCLog("HTML rendering"); MCLog("%s", MCUTF8(parser->htmlRendering())); MCLog("%s", MCUTF8(parser->plainTextBodyRendering(true))); MCLog("%s", MCUTF8(parser->plainTextBodyRendering(false))); }
bool MCSystemCreateEvent(char*& r_result) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 MCLog("MCSystemCreateCalendarEvent", NULL); MCAndroidEngineRemoteCall("createCalendarEvent", "v", nil); s_calendar_event_status = kMCAndroidCalendarEventWaiting; while (s_calendar_event_status == kMCAndroidCalendarEventWaiting) MCscreen->wait(60.0, False, True); MCLog("MCSystemCreateCalendarEvent - finished", NULL); return true; }
void MCCachedImageRep::FlushCache() { MCLog("MCImageRep::FlushCache() - %d bytes", s_cache_size); while (s_tail != nil) { s_tail->ReleaseFrames(); s_tail = s_tail->m_prev; } MCLog("%d bytes remaining", s_cache_size); }
bool MCSystemShowEvent(const char* p_calendar_event_id, char*& r_result) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 MCLog("MCSystemShowCalendarEvent", NULL); MCAndroidEngineRemoteCall("showCalendarEvent", "vs", nil, p_calendar_event_id); s_calendar_event_status = kMCAndroidCalendarEventWaiting; while (s_calendar_event_status == kMCAndroidCalendarEventWaiting) MCscreen->wait(60.0, False, True); r_result = s_calendar_event_selected.clone(); MCLog("MCSystemShowCalendarEvent - finished", NULL); return true; }
static void testAddresses() { mailcore::Address *addr = mailcore::Address::addressWithNonEncodedRFC822String(MCSTR("DINH Viêt Hoà <*****@*****.**>")); MCLog("%s %s", MCUTF8DESC(addr->nonEncodedRFC822String()), MCUTF8DESC(addr->RFC822String())); mailcore::Array *addresses = mailcore::Address::addressesWithNonEncodedRFC822String(MCSTR("My Email1 <*****@*****.**>, DINH Viêt Hoà <*****@*****.**>,\"Email3, My\" <*****@*****.**>")); MCLog("%s", MCUTF8DESC(addresses)); mailcore::String *str = mailcore::Address::nonEncodedRFC822StringForAddresses(addresses); MCLog("%s", MCUTF8DESC(str)); str = mailcore::Address::RFC822StringForAddresses(addresses); MCLog("%s", MCUTF8DESC(str)); }
void MCCachedImageRep::FlushCacheToLimit() { // allow tail to move forward - anything beyond the tail will have no frames // loaded or is locked & will move to head on unlock MCLog("MCImageRep::FlushCacheToLimit() - %d bytes", s_cache_size); while (s_cache_size > s_cache_limit && s_tail != nil) { s_tail->ReleaseFrames(); s_tail = s_tail->m_prev; } MCLog("%d bytes remaining", s_cache_size); }
void MCAndroidUpdateCalendarEventDone(const char* p_calendar_event_id) { // STILL TO BE IMPLEMENTED IPA LEVEL 14 s_calendar_event_selected = p_calendar_event_id; MCLog("MCAndroidUpdateCalendarEventDone() called %s", p_calendar_event_id); s_calendar_event_status = kMCAndroidCalendarEventDone; }
void MCAndroidShowCalendarEventCanceled(const char* p_calendar_event_id) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 s_calendar_event_selected = p_calendar_event_id; MCLog("MCAndroidShowCalendarEventCanceled() called %s", p_calendar_event_id); s_calendar_event_status = kMCAndroidCalendarEventCanceled; }
static void testAttachments() { mailcore::Attachment *attachment = mailcore::Attachment::attachmentWithText(MCSTR("Hello World")); attachment->setCharset(NULL); mailcore::String * str = attachment->decodedString(); MCLog("%s", MCUTF8DESC(str)); }
JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doConfirmNotificationResponse(JNIEnv *env, jobject object, jint purchaseId, jint responseCode) { MCLog("doConfirmNotificationResponse(purchaseId=%d, responseCode=%d", purchaseId, responseCode); MCPurchase *t_purchase = NULL; if (MCPurchaseFindById(purchaseId, t_purchase)) { if (responseCode == RESULT_OK) { switch (t_purchase->state) { case kMCPurchaseStatePaymentReceived: case kMCPurchaseStateRefunded: case kMCPurchaseStateRestored: t_purchase->state = kMCPurchaseStateComplete; MCPurchaseNotifyUpdate(t_purchase); break; case kMCPurchaseStateCancelled: break; } MCPurchaseRelease(t_purchase); } else { // TODO - handle errors } } }
void MCAndroidCreateCalendarEventDone(const char* p_calendar_event_id) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 s_calendar_event_selected = p_calendar_event_id; MCLog("MCAndroidCreateCalendarEventDone() called %s", p_calendar_event_id); s_calendar_event_status = kMCAndroidCalendarEventDone; }
bool MCSystemRemoveEvent(const char* p_calendar_event_id, bool p_reoccurring, char*& r_calendar_event_id_deleted) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 MCLog("MCSystemRemoveCalendarEvent: %s", p_calendar_event_id); MCAndroidEngineRemoteCall("removeCalendarEvent", "ss", &r_calendar_event_id_deleted, p_calendar_event_id); r_calendar_event_id_deleted = s_calendar_event_selected.clone(); return true; }
JNIEXPORT void JNICALL Java_com_runrev_android_nativecontrol_VideoControl_doPlayerError(JNIEnv *env, jobject object) { MCLog("doPlayerError", nil); MCAndroidControl *t_control = nil; if (MCAndroidControl::FindByView(object, t_control)) t_control->PostNotifyEvent(MCM_player_error); }
bool MCSystemFindEvent(MCDateTime p_start_date, MCDateTime p_end_date, char *& r_result) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 char *t_result; r_result = s_calendar_events_selected.clone(); MCLog("MCSystemFindCalendarEvent result: %s", r_result); return true; }
bool MCSystemGetEventData(MCExecContext &r_ctxt, const char* p_calendar_event_id, MCVariableValue *&r_calendar_event_data) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 MCLog("MCSystemGetEventData: %s", p_calendar_event_id); MCAndroidEngineRemoteCall("getCalendarEventData", "vs", nil, p_calendar_event_id); MCCalendarToArrayData (r_ctxt, s_calendar_event_data, r_calendar_event_data); return true; }
JNIEXPORT void JNICALL Java_com_runrev_android_nativecontrol_ScrollerControl_doScrollEndDrag(JNIEnv *env, jobject object) { MCLog("scrollViewEndDrag"); MCAndroidControl *t_control = nil; char *t_url = nil; if (MCAndroidControl::FindByView(object, t_control)) t_control->PostNotifyEvent(MCM_scroller_end_drag); }
void MCPurchaseVerify(MCPurchase *p_purchase, bool p_verified) { MCAndroidPurchase *t_android_data = (MCAndroidPurchase*)p_purchase->platform_data; if (p_purchase->state == kMCPurchaseStateUnverified) { if (p_verified) { switch (t_android_data->purchase_state) { case PURCHASED: p_purchase->state = kMCPurchaseStatePaymentReceived; break; case CANCELED: { //MCLog("verified canceled purchase", nil); p_purchase->state = kMCPurchaseStateCancelled; purchase_confirm(p_purchase); break; } case ALREADY_ENTITLED: { MCLog("found ALREADY_ENTITLED purchase", nil); p_purchase->state = kMCPurchaseStateAlreadyEntitled; break; } case INVALID_SKU: p_purchase->state = kMCPurchaseStateInvalidSKU; break; case REFUNDED: //MCLog("verified refunded purchase", nil); p_purchase->state = kMCPurchaseStateRefunded; break; case RESTORED: p_purchase->state = kMCPurchaseStateRestored; break; default: break; } MCPurchaseNotifyUpdate(p_purchase); } else { p_purchase->state = kMCPurchaseStateError; t_android_data->error = MCValueRetain(MCSTR("unable to verify message from billing service")); MCPurchaseNotifyUpdate(p_purchase); MCPurchaseRelease(p_purchase); } } }
static bool purchase_confirm(MCPurchase *p_purchase) { MCAndroidPurchase *t_android_data = (MCAndroidPurchase*)p_purchase->platform_data; bool t_result = false; MCLog("confirming notification: purchaseId=%d, notificationId=%@", p_purchase->id, t_android_data->notification_id); MCAndroidEngineRemoteCall("purchaseConfirmDelivery", "bix", &t_result, p_purchase->id, t_android_data->notification_id); return t_result; }
bool MCSystemAddEvent(MCCalendar p_new_calendar_event_data, char*& r_result) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 MCLog("MCSystemAddCalendarEvent", NULL); MCAndroidEngineRemoteCall("addCalendarEvent", "issssbbbbiisiis", &r_result, p_new_calendar_event_data.mceventid.getstring(), p_new_calendar_event_data.mctitle.getstring(), p_new_calendar_event_data.mcnote.getstring(), p_new_calendar_event_data.mclocation.getstring(), p_new_calendar_event_data.mcalldayset, p_new_calendar_event_data.mcallday, p_new_calendar_event_data.mcstartdateset, p_new_calendar_event_data.mcenddateset, p_new_calendar_event_data.mcalert1, p_new_calendar_event_data.mcalert2, p_new_calendar_event_data.mcfrequency.getstring(), p_new_calendar_event_data.mcfrequencycount, p_new_calendar_event_data.mcfrequencyinterval, p_new_calendar_event_data.mccalendar.getstring()); r_result = s_calendar_event_selected.clone(); return true; }
//public static native void doUrlError(int id, String error_str); JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doUrlError(JNIEnv *env, jobject object, int id, jstring error_string) { MCLog("doUrlError(id=%d)", id); MCUrlInfo *t_info = nil; if (getURLInfo(id, t_info)) { // TODO - once string conversion functions are implemented, switch to using // GetStringChars() (UTF16) then convert to native, rather than GetStringUTFChars() (UTF-8) const char *t_err_str = nil; t_err_str = env->GetStringUTFChars(error_string, nil); t_info->callback(t_info->context, kMCSystemUrlStatusError, t_err_str); env->ReleaseStringUTFChars(error_string, t_err_str); removeURLInfo(t_info); } }
static void testPOP() { mailcore::POPSession * session; mailcore::ErrorCode error; session = new mailcore::POPSession(); session->setHostname(MCSTR("pop.gmail.com")); session->setPort(995); session->setUsername(email); session->setPassword(password); session->setConnectionType(mailcore::ConnectionTypeTLS); mailcore::Array * messages = session->fetchMessages(&error); MCLog("%s", MCUTF8DESC(messages)); session->release(); }
void update_purchase_state(MCPurchase *p_purchase, int32_t p_state, bool p_verified) { MCLog("State is " + p_state, nil); if (!p_verified) p_purchase->state = kMCPurchaseStateUnverified; else if (p_state == PURCHASED) p_purchase->state = kMCPurchaseStatePaymentReceived; else if (p_state == ALREADY_ENTITLED) p_purchase->state = kMCPurchaseStateAlreadyEntitled; else if (p_state == INVALID_SKU) p_purchase->state = kMCPurchaseStateInvalidSKU; else if (p_state == REFUNDED) p_purchase->state = kMCPurchaseStateRefunded; else if (p_state == RESTORED) p_purchase->state = kMCPurchaseStateRestored; else p_purchase->state = kMCPurchaseStateCancelled; }
static mailcore::Data * testMessageBuilder() { mailcore::Address * address = new mailcore::Address(); address->setDisplayName(displayName); address->setMailbox(email); address->release(); mailcore::MessageBuilder * msg = new mailcore::MessageBuilder(); msg->header()->setFrom(mailcore::Address::addressWithDisplayName(displayName, email)); mailcore::Array * to = new mailcore::Array(); mailcore::Array * bcc = new mailcore::Array(); to->addObject(mailcore::Address::addressWithDisplayName(MCSTR("Foo Bar"), MCSTR("*****@*****.**"))); to->addObject(mailcore::Address::addressWithDisplayName(MCSTR("Other Recipient"), MCSTR("*****@*****.**"))); bcc->addObject(mailcore::Address::addressWithDisplayName(MCSTR("Hidden Recipient"), MCSTR("*****@*****.**"))); msg->header()->setTo(to); msg->header()->setBcc(bcc); to->release(); bcc->release(); MCAssert(msg->header()->allExtraHeadersNames()->count() == 0); msg->header()->setExtraHeader(MCSTR("X-Custom-Header"), MCSTR("Custom Header Value")); msg->header()->setSubject(MCSTR("Mon projet d'été")); msg->setHTMLBody(MCSTR("<div>Hello <img src=\"cid:1234\"></div>")); msg->addAttachment(mailcore::Attachment::attachmentWithContentsOfFile(MCSTR("first-filename"))); msg->addAttachment(mailcore::Attachment::attachmentWithContentsOfFile(MCSTR("second-filename"))); mailcore::Attachment * attachment = mailcore::Attachment::attachmentWithContentsOfFile(MCSTR("third-image-attachment")); attachment->setContentID(MCSTR("1234")); msg->addRelatedAttachment(attachment); mailcore::Data * data = msg->data(); MCLog("%s", data->bytes()); mailcore::MessageBuilder * msg2 = new mailcore::MessageBuilder(msg); mailcore::String *htmlBody = msg->htmlBody(); mailcore::String *htmlBody2 = msg2->htmlBody(); MCAssert(htmlBody->isEqual(htmlBody2)); msg->release(); msg2->release(); return data; }
JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doRequestPurchaseResponse(JNIEnv *env, jobject object, jint purchaseId, jint responseCode) { MCLog("doRequestPurchaseResponse(purchaseId=%d, responseCode=%d", purchaseId, responseCode); MCPurchase *t_purchase = NULL; if (MCPurchaseFindById(purchaseId, t_purchase)) { MCAndroidPurchase *t_android_data = (MCAndroidPurchase*)t_purchase->platform_data; if (responseCode == RESULT_OK) { // seems to be sent after purchase updates. } else if (responseCode == RESULT_USER_CANCELED) { t_purchase->state = kMCPurchaseStateCancelled; MCPurchaseNotifyUpdate(t_purchase); MCPurchaseRelease(t_purchase); } else if (responseCode == RESULT_ITEM_UNAVAILABLE) { t_purchase->state = kMCPurchaseStateError; t_android_data->error = MCSTR("requested item unavailable"); MCPurchaseNotifyUpdate(t_purchase); MCPurchaseRelease(t_purchase); } else if (responseCode == RESULT_DEVELOPER_ERROR) { t_purchase->state = kMCPurchaseStateError; t_android_data->error = MCSTR("developer error"); MCPurchaseNotifyUpdate(t_purchase); MCPurchaseRelease(t_purchase); } else if (responseCode == RESULT_ERROR) { t_purchase->state = kMCPurchaseStateError; t_android_data->error = MCSTR("sending purchase request failed"); MCPurchaseNotifyUpdate(t_purchase); MCPurchaseRelease(t_purchase); } } }
static void testNNTP() { mailcore::NNTPSession * session; mailcore::ErrorCode error; session = new mailcore::NNTPSession(); session->setHostname(MCSTR("news.gmane.org.")); session->setPort(119); // session->setUsername(email); // session->setPassword(password); session->setConnectionType(mailcore::ConnectionTypeClear); session->checkAccount(&error); mailcore::Array * messages = session->listAllNewsgroups(&error); MCLog("%s", MCUTF8DESC(messages)); session->release(); }
static void testIMAPMove() { mailcore::IMAPSession * session; mailcore::HashMap *uidMapping; mailcore::ErrorCode error; session = new mailcore::IMAPSession(); session->setHostname(MCSTR("imap.mail.ru")); session->setPort(993); session->setUsername(email); session->setPassword(password); session->setConnectionType(mailcore::ConnectionTypeTLS); session->moveMessages(MCSTR("INBOX"), mailcore::IndexSet::indexSetWithIndex(14990), MCSTR("Personal"), &uidMapping, &error); MCLog("mapping: %s, error: %i", MCUTF8DESC(uidMapping), error); session->release(); }
static void testIMAP() { mailcore::IMAPSession * session; mailcore::ErrorCode error; session = new mailcore::IMAPSession(); session->setHostname(MCSTR("imap.gmail.com")); session->setPort(993); session->setUsername(email); session->setPassword(password); session->setConnectionType(mailcore::ConnectionTypeTLS); mailcore::IMAPMessagesRequestKind requestKind = (mailcore::IMAPMessagesRequestKind) (mailcore::IMAPMessagesRequestKindHeaders | mailcore::IMAPMessagesRequestKindStructure | mailcore::IMAPMessagesRequestKindInternalDate | mailcore::IMAPMessagesRequestKindHeaderSubject | mailcore::IMAPMessagesRequestKindFlags); mailcore::Array * messages = session->fetchMessagesByUID(MCSTR("INBOX"), requestKind, mailcore::IndexSet::indexSetWithRange(mailcore::RangeMake(1, UINT64_MAX)), NULL, &error); MCLog("%s", MCUTF8DESC(messages)); session->release(); }
JNIEXPORT void JNICALL Java_com_runrev_android_nativecontrol_VideoControl_doPropertyAvailable(JNIEnv *env, jobject object, jint availableProperty) { MCLog("doPropertyAvailable", nil); MCAndroidControl *t_control = nil; if (MCAndroidControl::FindByView(object, t_control)) { const char *t_prop_name = nil; switch (availableProperty) { case kMCPlayerAvailablePropertyDuration: t_prop_name = "duration"; break; case kMCPlayerAvailablePropertyNaturalSize: t_prop_name = "naturalSize"; break; } MCAndroidPlayerControl *t_player = (MCAndroidPlayerControl*)t_control; MCCustomEvent *t_event; t_event = new MCNativePlayerPropertyAvailableEvent(t_player, t_prop_name); MCEventQueuePostCustom(t_event); } }
//stand-in implementation which just returns a new image rep bool MCImageRepGetReferenced(const char *p_filename, MCImageRep *&r_rep) { bool t_success = true; MCCachedImageRep *t_rep = nil; if (MCCachedImageRep::FindReferencedWithFilename(p_filename, t_rep)) { MCLog("image rep cache hit for file %s", p_filename); r_rep = t_rep->Retain(); return true; } t_rep = new MCReferencedImageRep(p_filename); t_success = t_rep != nil; if (t_success) { MCCachedImageRep::AddRep(t_rep); r_rep = t_rep->Retain(); } return t_success; }
bool MCImageRepGetDensityMapped(const char *p_filename, MCImageRep *&r_rep) { // try to resolve files in the following way: // if it has a density tag then // try to get referenced rep for the exact filename // if that fails, try to get referenced file with matching base name & scale // else // try to get density mapped set for the base filename bool t_success = true; MCImageRep *t_rep = nil; char *t_base, *t_extension; t_base = t_extension = nil; MCGFloat t_density; bool t_has_tag; t_success = MCImageSplitScaledFilename(p_filename, t_base, t_extension, t_has_tag, t_density); if (!t_success) return false; // check filename for density tag if (t_has_tag) t_success = MCImageRepGetReferencedWithScale(t_base, t_extension, t_density, t_rep); else { MCCachedImageRep *t_cached_rep; t_cached_rep = nil; if (MCCachedImageRep::FindWithKey(p_filename, t_cached_rep)) { MCLog("image rep cache hit for file %s", p_filename); t_rep = t_cached_rep->Retain(); } else { MCImageScaledRep *t_list; t_list = nil; uint32_t t_count; t_count = 0; t_success = MCImageGetScaledFiles(t_base, t_extension, t_list, t_count); if (t_success && t_count > 0) t_success = MCImageRepCreateDensityMapped(p_filename, t_list, t_count, t_rep); MCImageFreeScaledRepList(t_list, t_count); } } if (t_success) { r_rep = t_rep; } MCCStringFree(t_base); MCCStringFree(t_extension); return t_success; }