From fe38268ae37373016c8451002532f53336f220f7 Mon Sep 17 00:00:00 2001 From: Sangtai Kim Date: Thu, 23 Feb 2012 15:28:06 +0900 Subject: [PATCH] merge wrt-plugins-tizen_0.2.0-12 --- debian/changelog | 9 + src/platform/API/Calendar/IEventAddEvents.h | 12 +- src/platform/API/Calendar/IEventFindEvents.h | 11 ++ src/platform/API/Calendar/OnEventsChanged.h | 10 ++ src/platform/API/Messaging/ReqReceiverMessage.cpp | 29 +++- src/platform/Tizen/Calendar/Calendar.cpp | 1 + src/platform/Tizen/Contact/AddressBook.cpp | 40 +++-- src/platform/Tizen/Contact/ContactSearchEngine.cpp | 12 +- src/platform/Tizen/Contact/ContactWrapper.cpp | 3 +- src/platform/Tizen/Messaging/Conversation.cpp | 26 +-- src/standards/Tizen/Calendar/CalendarConverter.cpp | 24 ++- src/standards/Tizen/Calendar/CalendarConverter.h | 6 +- .../Tizen/Calendar/CalendarResponseDispatcher.cpp | 35 +++- src/standards/Tizen/Calendar/JSCalendar.cpp | 2 + .../Tizen/Calendar/JSCalendarItemProperties.cpp | 23 ++- .../Tizen/Contact/JSContactEmailAddress.cpp | 5 +- .../Tizen/Contact/JSContactPhoneNumber.cpp | 22 ++- src/standards/Tizen/Messaging/JSMessageBody.cpp | 2 +- .../Tizen/Messaging/JSMessagingService.cpp | 189 ++++++++++++++------- 19 files changed, 335 insertions(+), 126 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1786f60..2d80cec 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +wrt-plugins-tizen (0.2.0-12) unstable; urgency=low + + * Messaging and Calendar bug fix + * Git : slp/pkgs/w/wrt-plugins-tizen + * Tag : wrt-plugins-tizen_0.2.0-12 + + + -- Sangtai Kim Thu, 23 Feb 2012 15:07:02 +0900 + wrt-plugins-tizen (0.2.0-11) unstable; urgency=low * Systeminfo bug fix diff --git a/src/platform/API/Calendar/IEventAddEvents.h b/src/platform/API/Calendar/IEventAddEvents.h index a196407..5a56b7c 100755 --- a/src/platform/API/Calendar/IEventAddEvents.h +++ b/src/platform/API/Calendar/IEventAddEvents.h @@ -30,6 +30,7 @@ class IEventAddEvents : public WrtDeviceApis::Commons::IEvent { CalendarEventListPtr m_events; bool m_result; + CalendarEvent::CalendarType m_calendarType; public: void setResult(bool value) @@ -41,6 +42,15 @@ class IEventAddEvents : public WrtDeviceApis::Commons::IEvent return m_result; } + void setCalendarType(CalendarEvent::CalendarType value) + { + m_calendarType = value; + } + CalendarEvent::CalendarType getCalendarType() const + { + return m_calendarType; + } + void setEvents(CalendarEventListPtr value) { m_events = value; @@ -50,7 +60,7 @@ class IEventAddEvents : public WrtDeviceApis::Commons::IEvent return m_events; } - IEventAddEvents() : m_result(false) + IEventAddEvents() : m_result(false), m_calendarType(CalendarEvent::EVENT_TYPE) { LogDebug("entered"); } diff --git a/src/platform/API/Calendar/IEventFindEvents.h b/src/platform/API/Calendar/IEventFindEvents.h index 26ecea8..876c5ef 100755 --- a/src/platform/API/Calendar/IEventFindEvents.h +++ b/src/platform/API/Calendar/IEventFindEvents.h @@ -36,6 +36,7 @@ class IEventFindEvents : public WrtDeviceApis::Commons::IEvent CalendarEventListPtr m_events; bool m_result; EventFilterPtr m_filter; + CalendarEvent::CalendarType m_calendarType; /* generic filter parameters */ Tizen::FilterPtr m_genericFilter; @@ -64,6 +65,15 @@ class IEventFindEvents : public WrtDeviceApis::Commons::IEvent return m_result; } + void setCalendarType(CalendarEvent::CalendarType value) + { + m_calendarType = value; + } + CalendarEvent::CalendarType getCalendarType() const + { + return m_calendarType; + } + void addEvent(CalendarEventPtr value) { m_events->push_back(value); @@ -123,6 +133,7 @@ class IEventFindEvents : public WrtDeviceApis::Commons::IEvent } IEventFindEvents() : m_result(false), + m_calendarType(CalendarEvent::EVENT_TYPE), m_genericFilterIsSet(false), m_sortModesIsSet(false), m_attributesOfInterestIsSet(false) diff --git a/src/platform/API/Calendar/OnEventsChanged.h b/src/platform/API/Calendar/OnEventsChanged.h index 5435fd3..d9b0668 100755 --- a/src/platform/API/Calendar/OnEventsChanged.h +++ b/src/platform/API/Calendar/OnEventsChanged.h @@ -47,6 +47,15 @@ class OnEventsChanged : public WrtDeviceApis::Commons::ListenerEvent OnEventsChangedPtr; diff --git a/src/platform/API/Messaging/ReqReceiverMessage.cpp b/src/platform/API/Messaging/ReqReceiverMessage.cpp index 521845a..da6cd04 100755 --- a/src/platform/API/Messaging/ReqReceiverMessage.cpp +++ b/src/platform/API/Messaging/ReqReceiverMessage.cpp @@ -154,6 +154,28 @@ void ReqReceiverMessage::sync(const EventMessagingServicePtr& event) void ReqReceiverMessage::syncFolder(const EventMessagingServicePtr& event) { LogDebug("enter"); + + if (event && event->m_messagingService && event->m_messagingService->getAccountID() > 0) + { + //check pop3 folder + emf_account_t* accounts = NULL; + if (email_get_account( event->m_messagingService->getAccountID(), GET_FULL_DATA, &accounts)) + { + LogDebug("accounts[0].receiving_server_type = " << accounts[0].receiving_server_type); + LogDebug("m_folder_name = " << event->m_folder_name); + if ( accounts[0].receiving_server_type == EMF_SERVER_TYPE_POP3 && event->m_folder_name != "INBOX" ) + { + LogDebug("Can't Sync Folder because POP3 spec."); + ThrowMsg(WrtDeviceApis::Commons::UnsupportedException, "Operation Type is mismatched"); + } + + if (accounts != NULL) + { + email_free_account(&accounts, 1); + } + } + } + EventMessagingServiceReqReceiver::PostRequest(event); } @@ -171,8 +193,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventAddDraftMessagePtr& event) { Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg); Try { - - + if (email_get_account_list(&accounts, &count)) { if (0 < count) { @@ -475,6 +496,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event IMessagePtr msg = event->m_message; if(msg) { + msg->setRequestReceiver(this); msg->setMessagingServiceEvent(event); @@ -592,8 +614,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event LogDebug("messaging service type :" << type); event->m_messagingService->setRequestReceiver(this); - event->m_messagingService->setMessagingServiceEvent(event); // - + event->m_messagingService->setMessagingServiceEvent(event); if (type == Api::Messaging::EMAIL) { event->switchToManualAnswer(); //switch to manual answer; diff --git a/src/platform/Tizen/Calendar/Calendar.cpp b/src/platform/Tizen/Calendar/Calendar.cpp index 3d23af0..b72c676 100755 --- a/src/platform/Tizen/Calendar/Calendar.cpp +++ b/src/platform/Tizen/Calendar/Calendar.cpp @@ -863,6 +863,7 @@ static void eventChangedCb(void *user_data) LogInfo("Last change fetch time: "<getLastChangeFetchTime()); eventPtr->setResult(true); + eventPtr->setCalendarType(thisCalendar->getType()); if( eventPtr->getEventList()->size() > 0 ) { thisCalendar->m_changeEmitters.emit(eventPtr); diff --git a/src/platform/Tizen/Contact/AddressBook.cpp b/src/platform/Tizen/Contact/AddressBook.cpp index ab00a29..ab66928 100755 --- a/src/platform/Tizen/Contact/AddressBook.cpp +++ b/src/platform/Tizen/Contact/AddressBook.cpp @@ -73,7 +73,15 @@ void AddressBook::add(const ContactPtr &contact) ThrowMsg(InvalidArgumentException, "Contact argument is wrong"); internalAddContact(contact); - m_latestVersion = get_contact_version(); + + string id = contact->getId(); + if(id != "") + { + ContactPtr insertedContact = internalGetById(id); + contact->copy(insertedContact); + } + + //m_latestVersion = get_contact_version(); } void AddressBook::update(const ContactPtr &contact) @@ -83,7 +91,7 @@ void AddressBook::update(const ContactPtr &contact) ThrowMsg(InvalidArgumentException, "Contact argument is wrong"); internalAddContact(contact); - m_latestVersion = get_contact_version(); + //m_latestVersion = get_contact_version(); } void AddressBook::remove(const string &id) @@ -107,7 +115,7 @@ void AddressBook::remove(const string &id) LogError("Error during deleting contact. " << _rethrown_exception.GetMessage()); ThrowMsg(PlatformException, "Error during deleting contact."); } - m_latestVersion = get_contact_version(); + //m_latestVersion = get_contact_version(); } long AddressBook::addChangeListener(const EventAddressBookChangeListenerEmitterPtr &emitter) @@ -182,6 +190,18 @@ void AddressBook::OnRequestReceived(const EventAddressBookAddBatchPtr &event) LogError("error code " << ret); ThrowMsg(PlatformException, "Error during executing contacts_svc_end_trans()"); } + + for(ContactArray::iterator i = contacts->begin(); i != contacts->end(); i++) + { + ContactPtr contact = *i; + + string id = contact->getId(); + if(id != "") + { + ContactPtr insertedContact = internalGetById(id); + contact->copy(insertedContact); + } + } } Catch (NotFoundException) { @@ -198,7 +218,7 @@ void AddressBook::OnRequestReceived(const EventAddressBookAddBatchPtr &event) event->setExceptionCode(ExceptionCodes::PlatformException); return; } - m_latestVersion = get_contact_version(); + //m_latestVersion = get_contact_version(); event->setResult(true); event->setExceptionCode(ExceptionCodes::None); @@ -259,7 +279,7 @@ void AddressBook::OnRequestReceived(const EventAddressBookUpdateBatchPtr &event) event->setExceptionCode(ExceptionCodes::PlatformException); return; } - m_latestVersion = get_contact_version(); + //m_latestVersion = get_contact_version(); event->setResult(true); event->setExceptionCode(ExceptionCodes::None); @@ -337,7 +357,7 @@ void AddressBook::OnRequestReceived(const EventAddressBookRemoveBatchPtr &event) event->setExceptionCode(ExceptionCodes::PlatformException); return; } - m_latestVersion = get_contact_version(); + //m_latestVersion = get_contact_version(); event->setResult(true); event->setExceptionCode(ExceptionCodes::None); @@ -454,13 +474,7 @@ void AddressBook::internalAddContact(const ContactPtr &newContact) LogError("error code " << id); ThrowMsg(PlatformException, "Error during executing contacts_svc_insert_contact()"); } - - std::stringstream oss; - oss << id; - std::string idStr = oss.str(); - ContactPtr insertedContact = internalGetById(idStr); - - newContact->copy(insertedContact); + newContact->setId(id); } } diff --git a/src/platform/Tizen/Contact/ContactSearchEngine.cpp b/src/platform/Tizen/Contact/ContactSearchEngine.cpp index 8e9c16b..f070495 100755 --- a/src/platform/Tizen/Contact/ContactSearchEngine.cpp +++ b/src/platform/Tizen/Contact/ContactSearchEngine.cpp @@ -625,23 +625,23 @@ void ContactSearchEngine::setName(ContactPtr& contact, contactName = contact->getName(); if( prefix ) - contactName->setFirstName(prefix); + contactName->setPrefix(prefix); if( firstName ) - contactName->setLastName(firstName); + contactName->setFirstName(firstName); if( middleName ) contactName->setMiddleName(middleName); if( lastName ) - contactName->setDisplayName(lastName); - - if( phoneticName ) - contactName->setPrefix(phoneticName); + contactName->setLastName(lastName); if( phoneticName ) contactName->setPhoneticName(phoneticName); + if( displayName ) + contactName->setDisplayName(displayName); + if(!contact->getNameIsSet()) contact->setName(contactName); } diff --git a/src/platform/Tizen/Contact/ContactWrapper.cpp b/src/platform/Tizen/Contact/ContactWrapper.cpp index 891ddf5..9487a62 100755 --- a/src/platform/Tizen/Contact/ContactWrapper.cpp +++ b/src/platform/Tizen/Contact/ContactWrapper.cpp @@ -285,7 +285,7 @@ bool ContactWrapper::convertToAbstractBaseData() if (CTS_SUCCESS == errorCode && value != NULL) { const char *charValue = NULL; - ContactNamePtr contactName = m_abstractContact->getName(); + ContactNamePtr contactName(new ContactName); charValue = contacts_svc_value_get_str(value, CTS_NAME_VAL_FIRST_STR); if (charValue) @@ -311,6 +311,7 @@ bool ContactWrapper::convertToAbstractBaseData() //if (charValue) // contactName->setPhoneticName(charValue); + m_abstractContact->setName(contactName); } else if (errorCode != CTS_ERR_NO_DATA || value == NULL) { diff --git a/src/platform/Tizen/Messaging/Conversation.cpp b/src/platform/Tizen/Messaging/Conversation.cpp index a1deaa3..3606138 100755 --- a/src/platform/Tizen/Messaging/Conversation.cpp +++ b/src/platform/Tizen/Messaging/Conversation.cpp @@ -452,28 +452,34 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId) try { + // Todo : will be re-implemented as using email_get_thread_information_ex if(email_get_thread_information_ex(emailTreadId, &resultMail) != EMF_ERROR_NONE) { ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get email thread fail" ); } + if (!resultMail) + { + return NULL; + } if (email_get_mail(&mailbox, resultMail->mail_id, &mail) != EMF_ERROR_NONE) { ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get email data fail" ); } - - + // account Id m_unreadMessages = 0; - + + LogDebug("start email_get_mail_list_ex"); if (email_get_mail_list_ex(accountId, NULL, emailTreadId, 0, resultMail->thread_item_count, EMF_SORT_DATETIME_HIGH, &mailList, &count) != EMF_ERROR_NONE) { ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get email data fail" ); } - + LogDebug("end email_get_mail_list_ex"); + // unread msg count accountId = resultMail->account_id; @@ -544,11 +550,10 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId) LogDebug(mail->head->previewBodyText); m_preview = mail->head->previewBodyText; } -#endif +#endif // read m_read = (bool)resultMail->flags_seen_field; - // from if (resultMail->from[0] != '\0') { @@ -596,16 +601,17 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId) LogError("Exception: " << ex.GetMessage()); } - if (resultMail != NULL) + if (mail != NULL) { - free(resultMail); + email_free_mail(&mail , 1); } - if (mail != NULL) + if (resultMail != NULL) { - email_free_mail(&mail , 1); + free(resultMail); } + return m_result; } diff --git a/src/standards/Tizen/Calendar/CalendarConverter.cpp b/src/standards/Tizen/Calendar/CalendarConverter.cpp index 60901f7..d5b4cd5 100755 --- a/src/standards/Tizen/Calendar/CalendarConverter.cpp +++ b/src/standards/Tizen/Calendar/CalendarConverter.cpp @@ -19,6 +19,8 @@ #include #include #include "JSCalendarItem.h" +#include "JSCalendarEvent.h" +#include "JSCalendarTask.h" #include "JSCalendarItemProperties.h" #include "JSCalendarEventId.h" #include "JSCalendarItemGeo.h" @@ -74,11 +76,31 @@ JSValueRef CalendarConverter::toJSValueRefItem(const CalendarEventPtr& arg) return JSUtils::makeObject(m_context, JSCalendarItem::getClassRef(), arg); } -JSValueRef CalendarConverter::toJSValueRef(const CalendarEventListPtr &arg) +JSValueRef CalendarConverter::toJSValueRefEvent(const CalendarEventPtr& arg) +{ + return JSUtils::makeObject(m_context, JSCalendarEvent::getClassRef(), arg); +} + +JSValueRef CalendarConverter::toJSValueRefTask(const CalendarEventPtr& arg) +{ + return JSUtils::makeObject(m_context, JSCalendarTask::getClassRef(), arg); +} + +JSValueRef CalendarConverter::toJSValueRefItemArray(const CalendarEventListPtr &arg) { return toJSValueRef_(*arg, &CalendarConverter::toJSValueRefItem, this); } +JSValueRef CalendarConverter::toJSValueRefEventArray(const CalendarEventListPtr &arg) +{ + return toJSValueRef_(*arg, &CalendarConverter::toJSValueRefEvent, this); +} + +JSValueRef CalendarConverter::toJSValueRefTaskArray(const CalendarEventListPtr &arg) +{ + return toJSValueRef_(*arg, &CalendarConverter::toJSValueRefTask, this); +} + JSValueRef CalendarConverter::toJSValueRefCalendar(const ICalendarPtr& arg) { CalendarPrivObject *priv = new CalendarPrivObject(m_context, arg); diff --git a/src/standards/Tizen/Calendar/CalendarConverter.h b/src/standards/Tizen/Calendar/CalendarConverter.h index 4f0ccbe..741dcd9 100755 --- a/src/standards/Tizen/Calendar/CalendarConverter.h +++ b/src/standards/Tizen/Calendar/CalendarConverter.h @@ -70,7 +70,11 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::TaskPriority abstractValue) const; JSValueRef toJSValueRefItem(const TizenApis::Api::Calendar::CalendarEventPtr& arg); - JSValueRef toJSValueRef(const TizenApis::Api::Calendar::CalendarEventListPtr &arg); + JSValueRef toJSValueRefEvent(const TizenApis::Api::Calendar::CalendarEventPtr& arg); + JSValueRef toJSValueRefTask(const TizenApis::Api::Calendar::CalendarEventPtr& arg); + JSValueRef toJSValueRefItemArray(const TizenApis::Api::Calendar::CalendarEventListPtr &arg); + JSValueRef toJSValueRefEventArray(const TizenApis::Api::Calendar::CalendarEventListPtr &arg); + JSValueRef toJSValueRefTaskArray(const TizenApis::Api::Calendar::CalendarEventListPtr &arg); JSValueRef toJSValueRefCalendar(const TizenApis::Api::Calendar::ICalendarPtr& arg); JSValueRef toJSValueRef(const std::vector &arg); diff --git a/src/standards/Tizen/Calendar/CalendarResponseDispatcher.cpp b/src/standards/Tizen/Calendar/CalendarResponseDispatcher.cpp index 2516dc6..cbe90b5 100755 --- a/src/standards/Tizen/Calendar/CalendarResponseDispatcher.cpp +++ b/src/standards/Tizen/Calendar/CalendarResponseDispatcher.cpp @@ -106,7 +106,15 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventAddEventsPtr &even LogDebug("result success"); CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(cbm->getContext()); - cbm->callOnSuccess(converter->toJSValueRef(event->getEvents())); + + JSValueRef result; + if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { + result = converter->toJSValueRefTaskArray(event->getEvents()); + } else { + result = converter->toJSValueRefEventArray(event->getEvents()); + } + + cbm->callOnSuccess(result); return; } LogDebug("result fail"); @@ -295,7 +303,12 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventFindEventsPtr &eve CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(cbm->getContext()); - JSValueRef result = converter->toJSValueRef(event->getEvents()); + JSValueRef result; + if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { + result = converter->toJSValueRefTaskArray(event->getEvents()); + } else { + result = converter->toJSValueRefEventArray(event->getEvents()); + } cbm->callOnSuccess(result); return; } else { @@ -337,7 +350,7 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventExpandEventRecurre if (event->getResult()) { CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(cbm->getContext()); - cbm->callOnSuccess(converter->toJSValueRef(event->getExpandedEventList())); + cbm->callOnSuccess(converter->toJSValueRefEventArray(event->getExpandedEventList())); return; } else { JSValueRef errorObject; @@ -371,6 +384,7 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& even JSContextRef context = multiCallbacks->getOnAdded()->getContext(); CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context); + JSValueRef result; Try { @@ -378,12 +392,23 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& even { case OnEventsChanged::ON_ADD: { - multiCallbacks->getOnAdded()->callOnSuccess(converter->toJSValueRef(event->getEventList())); + if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { + result = converter->toJSValueRefTaskArray(event->getEventList()); + } else { + result = converter->toJSValueRefEventArray(event->getEventList()); + } + + multiCallbacks->getOnAdded()->callOnSuccess(result); break; } case OnEventsChanged::ON_UPDATE: { - multiCallbacks->getOnUpdated()->callOnSuccess(converter->toJSValueRef(event->getEventList())); + if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { + result = converter->toJSValueRefTaskArray(event->getEventList()); + } else { + result = converter->toJSValueRefEventArray(event->getEventList()); + } + multiCallbacks->getOnUpdated()->callOnSuccess(result); break; } case OnEventsChanged::ON_DELETE: diff --git a/src/standards/Tizen/Calendar/JSCalendar.cpp b/src/standards/Tizen/Calendar/JSCalendar.cpp index 5aac8ad..5bdb7b0 100755 --- a/src/standards/Tizen/Calendar/JSCalendar.cpp +++ b/src/standards/Tizen/Calendar/JSCalendar.cpp @@ -296,6 +296,7 @@ JSValueRef JSCalendar::addBatch(JSContextRef context, //calendar->setAddEmitter(emitter); IEventAddEventsPtr dplEvent(new IEventAddEvents()); + dplEvent->setCalendarType(calendar->getType()); dplEvent->setEvents(events); dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); @@ -858,6 +859,7 @@ JSValueRef JSCalendar::find(JSContextRef context, } IEventFindEventsPtr dplEvent(new IEventFindEvents()); + dplEvent->setCalendarType(calendar->getType()); dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); diff --git a/src/standards/Tizen/Calendar/JSCalendarItemProperties.cpp b/src/standards/Tizen/Calendar/JSCalendarItemProperties.cpp index fb7304f..7dba891 100755 --- a/src/standards/Tizen/Calendar/JSCalendarItemProperties.cpp +++ b/src/standards/Tizen/Calendar/JSCalendarItemProperties.cpp @@ -663,11 +663,12 @@ JSValueRef JSCalendarItemProperties::getPropertyAlarms(JSContextRef context, LogDebug("entered"); Try { - CalendarConverterFactory::ConverterType converter = - CalendarConverterFactory::getConverter(context); + CalendarItemPropertiesPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + CalendarEventPtr event = getPrivateObject(object); - JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL); + JSObjectRef jsResult = JSCreateArrayObject(priv->getContext(), 0, NULL); if (NULL == jsResult) { ThrowMsg(NullPointerException, "Could not create js array object"); } @@ -683,7 +684,7 @@ JSValueRef JSCalendarItemProperties::getPropertyAlarms(JSContextRef context, alarm->setTimeZone(event->getTimeZone()); alarm->setDescription(event->getAlarmsDescription().at(i)); - if (!JSSetArrayElement(context, jsResult, i, JSCalendarAlarm::createJSCalendarAlarm(context, alarm))) { + if (!JSSetArrayElement(priv->getContext(), jsResult, i, JSCalendarAlarm::createJSCalendarAlarm(priv->getContext(), alarm))) { ThrowMsg(UnknownException, "Could not insert value into js array"); } } @@ -984,13 +985,14 @@ JSValueRef JSCalendarItemProperties::getPropertyRecurrenceRule(JSContextRef cont LogDebug("entered"); Try { - CalendarConverterFactory::ConverterType converter = - CalendarConverterFactory::getConverter(context); + CalendarItemPropertiesPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + CalendarEventPtr event = getPrivateObject(object); EventRecurrenceRulePtr rrule = event->getRecurrenceRule(); if (rrule) { - return JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(context, rrule); + return JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(priv->getContext(), rrule); } } Catch(Exception) @@ -1130,15 +1132,18 @@ JSValueRef JSCalendarItemProperties::getPropertyAttendees(JSContextRef context, LogDebug("entered"); Try { + CalendarItemPropertiesPrivObject *priv = + static_cast(JSObjectGetPrivate(object)); + CalendarEventPtr event = getPrivateObject(object); EventAttendeeListPtr attendees = event->getAttendees(); if (attendees) { - JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL); + JSObjectRef jsResult = JSCreateArrayObject(priv->getContext(), 0, NULL); if (NULL == jsResult) { ThrowMsg(NullPointerException, "Could not create js array object"); } for(unsigned int i=0; isize(); i++) { - if (!JSSetArrayElement(context, jsResult, i, JSCalendarAttendee::createJSCalendarAttendee(context, attendees->at(i)))) { + if (!JSSetArrayElement(priv->getContext(), jsResult, i, JSCalendarAttendee::createJSCalendarAttendee(priv->getContext(), attendees->at(i)))) { ThrowMsg(UnknownException, "Could not insert value into js array"); } } diff --git a/src/standards/Tizen/Contact/JSContactEmailAddress.cpp b/src/standards/Tizen/Contact/JSContactEmailAddress.cpp index 8aea395..dadcd51 100755 --- a/src/standards/Tizen/Contact/JSContactEmailAddress.cpp +++ b/src/standards/Tizen/Contact/JSContactEmailAddress.cpp @@ -209,6 +209,8 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context, if(JSIsArrayValue(gContext, arguments[1])) types = converter->toContactEmailAddressTypeArray(arguments[1]); } + if(types == NULL) + types = ContactEmailAddressTypeArrayPtr(new ContactEmailAddressTypeArray()); } Catch(Exception) { LogError("Argument type mismatch : " << _rethrown_exception.GetMessage()); *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments"); @@ -217,8 +219,7 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context, ContactEmailAddressPtr contactEmailAddress(new ContactEmailAddress()); contactEmailAddress->setEmail(email); - if(types != NULL) - contactEmailAddress->setTypes(types); + contactEmailAddress->setTypes(types); JSObjectRef jsobject; diff --git a/src/standards/Tizen/Contact/JSContactPhoneNumber.cpp b/src/standards/Tizen/Contact/JSContactPhoneNumber.cpp index b17f12b..f0c6ca2 100755 --- a/src/standards/Tizen/Contact/JSContactPhoneNumber.cpp +++ b/src/standards/Tizen/Contact/JSContactPhoneNumber.cpp @@ -172,14 +172,17 @@ JSObjectRef JSContactPhoneNumber::constructor(JSContextRef context, BasicValidator validator = BasicValidatorFactory::getValidator(context, exception); Try { - if (argumentCount != 2) + if (argumentCount < 1 || argumentCount > 2) ThrowMsg(InvalidArgumentException, "Wrong arguments count."); if (!JSValueIsString(gContext, arguments[0])) ThrowMsg(InvalidArgumentException, "1st argument is not string."); - if (!JSIsArrayValue(gContext, arguments[1])) - ThrowMsg(InvalidArgumentException, "2nd argument is not array."); + if (argumentCount >= 2) + { + if (!JSIsArrayValue(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1])) + ThrowMsg(InvalidArgumentException, "2nd argument is not array."); + } } Catch(Exception ) { LogError("Argument type mismatch : " << _rethrown_exception.GetMessage()); @@ -190,7 +193,7 @@ JSObjectRef JSContactPhoneNumber::constructor(JSContextRef context, ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext); std::string number; - ContactPhoneNumberTypeArrayPtr types; + ContactPhoneNumberTypeArrayPtr types(NULL); Try { number = converter->toString(arguments[0]); @@ -201,9 +204,16 @@ JSObjectRef JSContactPhoneNumber::constructor(JSContextRef context, } Try { - types = converter->toContactPhoneNumberTypeArray(arguments[1]); - if(types->size() == 0) + if(argumentCount >= 2) + { + if(JSIsArrayValue(gContext, arguments[1])) + types = converter->toContactPhoneNumberTypeArray(arguments[1]); + } + if(types == NULL) + { + types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray()); types->push_back(CONTACT_PHONE_NUMBER_TYPE_VOICE); + } } Catch(Exception) { LogError("Argument type mismatch : " << _rethrown_exception.GetMessage()); *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments"); diff --git a/src/standards/Tizen/Messaging/JSMessageBody.cpp b/src/standards/Tizen/Messaging/JSMessageBody.cpp index 060d842..9171b82 100755 --- a/src/standards/Tizen/Messaging/JSMessageBody.cpp +++ b/src/standards/Tizen/Messaging/JSMessageBody.cpp @@ -164,7 +164,7 @@ JSValueRef JSMessageBody::getLoadedStatus(JSContextRef context, { //Api::Messaging::IEmailPtr email = DPL::StaticPointerCast(Api::Messaging::MessageFactory::convertToEmail(msg)); Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg); - return converter.toJSValueRef(email->isBodyDownloaded()); + return converter.toJSValueRef(email->isBodyDownloaded() > 0 ? true : false); } else { diff --git a/src/standards/Tizen/Messaging/JSMessagingService.cpp b/src/standards/Tizen/Messaging/JSMessagingService.cpp index 455a9db..fd855db 100755 --- a/src/standards/Tizen/Messaging/JSMessagingService.cpp +++ b/src/standards/Tizen/Messaging/JSMessagingService.cpp @@ -484,28 +484,60 @@ JSValueRef JSMessagingService::loadMessageBody(JSContextRef context, MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY]); TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager); - if (JSValueIsObject(context, arguments[0]) && Validator(context).isCallback(arguments[0])) //check + if ( JSValueIsObject(context, arguments[0]) ) { - callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[0])); - if (converter->toFunctionOrNull(arguments[1]) && Validator(context).isCallback(arguments[1]) ) - { - callbackManager->setOnError(converter->toFunctionOrNull(arguments[1])); + switch(argumentCount){ + case 3: + { + if ( Validator(context).isCallback(arguments[2])) + { + callbackManager->setOnError(converter->toFunctionOrNull(arguments[2])); + } + else + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT); + } + } + case 2: + { + if ( Validator(context).isCallback(arguments[1])) + { + callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1])); + } + else + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT); + } + } } - Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService()); //create event - if ( JSValueIsObject(context, arguments[2]) ) - { - event->m_message = converter->toIMessage(arguments[2]) ; + Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService()); //create even + event->m_message = converter->toIMessage(arguments[0]) ; + if ( event->m_message ) + { + int msgType = event->m_message->getMessageType(); LogDebug("Message Type =" << event->m_message->getMessageType()); - privateData->setMessageJSValueRef(arguments[2]); //set Message JSValueRef. - } - else - { - return JSTizenExceptionFactory::postException(context, exception, - JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT); + if (msgType == Api::Messaging::EMAIL) + { + Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(event->m_message); + if (email && email->isBodyDownloaded() > 0) + { + callbackManager->callOnSuccess(arguments[0]); + return JSValueMakeNull(context); + } + } + else + { + callbackManager->callOnSuccess(arguments[0]); + return JSValueMakeNull(context); + } + + privateData->setMessageJSValueRef(arguments[0]); //set Message JSValueRef. } - IMessagingServicePtr imessagingService = priv->getObject(); + IMessagingServicePtr imessagingService = priv->getObject(); int opId = imessagingService->createOpId(MESSAGING_SERVICE_OP_DOWNLOAD_BODY); LogDebug("Operation ID is = " << opId); @@ -579,73 +611,95 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context, Try { - if (JSValueIsObject(context, arguments[0]) && Validator(context).isCallback(arguments[0])) //check + //check permission. + AceSecurityStatus status = MESSAGING_CHECK_ACCESS( + priv->getContext(), + MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT]); + TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager); + + if (JSValueIsObject(context, arguments[0]) && !JSValueIsNull(context, arguments[0])) { EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager) ); + if (!privateData) + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN); - callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[0])); - if (converter->toFunctionOrNull(arguments[1]) && Validator(context).isCallback(arguments[1]) ) - { - callbackManager->setOnError(converter->toFunctionOrNull(arguments[1])); + switch(argumentCount){ + case 3: + { + if ( Validator(context).isCallback(arguments[2])) + { + callbackManager->setOnError(converter->toFunctionOrNull(arguments[2])); + } + else + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT); + } + } + case 2: + { + if ( Validator(context).isCallback(arguments[1])) + { + callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1])); + } + else + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT); + } + } } - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - priv->getContext(), - MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT]); - TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager); - - IMessagingServicePtr imessagingService = priv->getObject(); Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService()); //create event - - LogInfo("event"); - event->setEventType(EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT); event->setPrivateData(DPL::StaticPointerCast(privateData)); event->setForAsynchronousCall(&MessagingController::getInstance()); - LogInfo("agu"); - if (argumentCount == 3 && !JSValueIsNull(context, arguments[2])) - { - Api::Messaging::IAttachmentPtr iAttchmentPtr = converter->toIAttachment(arguments[2]); - privateData->setMessageJSValueRef(arguments[2]); //set Message JSValueRef. - if (iAttchmentPtr) - { - event->m_attachment = iAttchmentPtr; - event->m_message = event->m_attachment->getMessage(); - - if (!event->m_message) - return JSTizenExceptionFactory::postException(context, exception, - JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN); - } - else - { + + Api::Messaging::IAttachmentPtr iAttchmentPtr = converter->toIAttachment(arguments[0]); + if (iAttchmentPtr) + { + event->m_attachment = iAttchmentPtr; + event->m_message = event->m_attachment->getMessage(); + + if (!event->m_message) return JSTizenExceptionFactory::postException(context, exception, - JSTizenException::NOT_FOUND_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_FOUND); - } + JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN); + + privateData->setMessageJSValueRef(arguments[0]); //set attachment JSValueRef. } else { - return JSTizenExceptionFactory::postException(context, exception, - JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT); + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_FOUND_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_FOUND); } - - int opId = imessagingService->createOpId(MESSAGING_SERVICE_OP_DOWNLOAD_ATTACHMENT); - LogDebug("Operation ID is = " << opId); - - event->opId = opId; - imessagingService->setMessageToOpId(opId, event->m_message); - LogInfo("pendingOperation"); - //JSValueRef pendingOperation = WrtDeviceApis::CommonsJavaScript::makePendingOperation(globalContext, event); //create pendingOperation. - Api::Messaging::ReqReceiverMessageSingleton::Instance().loadMessageAttachment(event); //load message Body - - return converter->toJSValueRef(event->opId); + IMessagingServicePtr imessagingService = priv->getObject(); + if (imessagingService) + { + int opId = imessagingService->createOpId(MESSAGING_SERVICE_OP_DOWNLOAD_ATTACHMENT); + LogDebug("Operation ID is = " << opId); + event->opId = opId; + imessagingService->setMessageToOpId(opId, event->m_message); + + //JSValueRef pendingOperation = WrtDeviceApis::CommonsJavaScript::makePendingOperation(globalContext, event); //create pendingOperation. + Api::Messaging::ReqReceiverMessageSingleton::Instance().loadMessageAttachment(event); //load message Body + + return converter->toJSValueRef(event->opId); + } + else + { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_FOUND_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_FOUND); + } + + } else { return JSTizenExceptionFactory::postException(context, exception, - JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT); + JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT); } } @@ -803,7 +857,6 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func IMessagingServicePtr imessagingService = priv->getObject(); //get MessagingService. - Api::Messaging::MessageType msgType = (Api::Messaging::MessageType)imessagingService->getType(); LogInfo("msgType :" << msgType); @@ -813,7 +866,6 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func if (JSValueIsObject(context, arguments[0]) && !Validator(context).isCallback(arguments[0])) //check { - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( priv->getContext(), MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER]); @@ -828,7 +880,8 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func IMessageFolderPtr folder = converter->toIMessageFolder(arguments[0]); if ( folder ) { - event->m_folder_name = folder->getName(); //it will be changed to the folder ptr + //event->m_folder_name = folder->getName(); //it will be changed to the folder ptr + event->m_folder_name = folder->getPath(); //it will be changed to the folder ptr } if ( argumentCount > 1 ) @@ -873,6 +926,10 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH); } } + Catch(WrtDeviceApis::Commons::UnsupportedException) { + return JSTizenExceptionFactory::postException(context, exception, + JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED); + } Catch(WrtDeviceApis::Commons::ConversionException) { return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH); -- 2.7.4