Flora license update
[apps/osp/Internet.git] / src / IntSharePopup.cpp
index 3e1c97a..e530bf9 100644 (file)
@@ -2,7 +2,7 @@
 
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
@@ -127,7 +127,7 @@ SharePopup::Initialize(void)
        __pShareList = new(std::nothrow) ArrayList();
        __pShareList->Construct();
 
-       __pList = static_cast<ListView*>(GetControl(L"IDC_POPUP_LIST"));
+       __pList = static_cast<ListView*>(GetControl(L"IDC_LISTVIEW"));
        if (__pList == null)
        {
                return false;
@@ -136,7 +136,7 @@ SharePopup::Initialize(void)
        __pList->SetItemProvider(*this);
        __pList->AddListViewItemEventListener(*this);
 
-       pCancelButton = static_cast< Button* >(GetControl(L"IDC_BUTTON", true));
+       pCancelButton = static_cast< Button* >(GetControl(L"IDC_BUTTON1", true));
        if (pCancelButton)
        {
                pCancelButton->AddActionEventListener(*this);
@@ -183,18 +183,20 @@ SharePopup::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView,
        {
        case 0:
        {
-               Popup::SetShowState(false);
-               Popup::Show();
+
                // share via message
                StartMessageAppControl();
+               Popup::SetShowState(false);
+               Popup::Show();
        }
        break;
        case 1:
        {
-               Popup::SetShowState(false);
-               Popup::Show();
+
                // share via email
                StartEmailAppControl();
+               Popup::SetShowState(false);
+               Popup::Show();
        }
        break;
        default:
@@ -221,7 +223,7 @@ SharePopup::CreateItem(int index, int itemWidth)
        ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
        int textSize = 35;
        int elementHeight = 50;
-       int listItemWidth = 112;
+       int listItemWidth = 80;
 
        CustomItem* pItem = new(std::nothrow) CustomItem();
        r = pItem->Construct(Dimension(GetClientAreaBounds().width, listItemWidth), style);
@@ -238,14 +240,14 @@ SharePopup::CreateItem(int index, int itemWidth)
        {
                AppLogDebug("SharePopUp CreateItem 0");
                // IDS_SHARE_VIA_MESSAGE
-               pItem->AddElement(Rectangle(0,0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_MESSAGE_STRING, CommonUtil::GetString(L"IDS_BR_OPT_SHARE_VIA_MESSAGES"), true);
+               pItem->AddElement(Rectangle(45,0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_MESSAGE_STRING, CommonUtil::GetString(L"IDS_BR_OPT_SHARE_VIA_MESSAGES"), true);
        }
        break;
        case 1:
        {
                AppLogDebug("SharePopUp CreateItem 1");
                // IDS_SHARE_VIA_EMAIL
-               pItem->AddElement(Rectangle(0, 0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_EMAIL_STRING, CommonUtil::GetString(L"IDS_BR_OPT_SHARE_VIA_EMAIL"), true);
+               pItem->AddElement(Rectangle(45, 0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_EMAIL_STRING, CommonUtil::GetString(L"IDS_BR_OPT_SHARE_VIA_EMAIL"), true);
        }
        break;
        default:
@@ -314,17 +316,19 @@ SharePopup::StartEmailAppControl(void)
                textVal.Append(L">");
        }
 
-   String subjectKey = L"subject";
+   String subjectKey = L"http://tizen.org/appcontrol/data/subject";
    String subjectVal = L"";
-   String textKey = L"text";
+   String textKey = L"http://tizen.org/appcontrol/data/text";
 
-   String toKey = L"to";
+   String toKey = L"http://tizen.org/appcontrol/data/to";
    String toVal = L"";
-   String ccKey = L"cc";
+   String ccKey = L"http://tizen.org/appcontrol/data/cc";
    String ccVal = L"";
-   String bccKey = L"bcc";
+   String bccKey = L"http://tizen.org/appcontrol/data/bcc";
    String bccVal = L"";
-   String attachKey = L"attachments";
+
+   //String attachKey = L"attachments";
+   String attachKey = L"http://tizen.org/appcontrol/data/path";
    String attachVal;
        if (pShareInfo != null)
        {
@@ -340,23 +344,34 @@ SharePopup::StartEmailAppControl(void)
                }
        }
 
+       ArrayList* pDataList = null;
+       pDataList = new (std::nothrow) ArrayList();
+       pDataList->Construct();
+       pDataList->Add(&attachVal);
+
    extraData.Add(&subjectKey, &subjectVal);
    extraData.Add(&textKey, &textVal);
    extraData.Add(&toKey, &toVal);
    extraData.Add(&ccKey, &ccVal);
    extraData.Add(&bccKey, &bccVal);
-   extraData.Add(&attachKey, &attachVal);
+   if(attachVal.GetLength() > 0)
+   {
+          extraData.Add(&attachKey, pDataList);
+   }
 
    AppControl* pAc = AppManager::FindAppControlN(L"tizen.email", L"http://tizen.org/appcontrol/operation/compose");
    if (pAc)
    {
-          pAc->Start(null, null, &extraData, null);
+         r = pAc->Start(null, null, &extraData, this);
           delete pAc;
    }
+
    if (pShareInfo != null)
-       {
-               delete pShareInfo;
-       }
+   {
+          delete pShareInfo;
+   }
+   delete pDataList;
+
 }
 
 void
@@ -364,9 +379,19 @@ SharePopup::StartMessageAppControl(void)
 {
        HashMap extraData;
        ShareInfo* pShareInfo = null;
+       result r = E_FAILURE;
+       bool imageAttachment = false;
 
        extraData.Construct();
 
+       String typeKey = L"http://tizen.org/appcontrol/data/message/type";
+       String typeVal;
+       String textKey = L"http://tizen.org/appcontrol/data/text";
+       String textVal;
+       String attachKey = L"http://tizen.org/appcontrol/data/path";
+       String attachVal;
+       ArrayList* pDataList = null;
+
        if (__pShareList != null)
        {
                pShareInfo = dynamic_cast<ShareInfo*>(__pShareList->GetAt(0));
@@ -377,36 +402,95 @@ SharePopup::StartMessageAppControl(void)
                }
        }
 
-       String textVal;
-
        if (pShareInfo != null)
        {
                textVal.Append(pShareInfo->GetPageTitle());
-               textVal.Append(L" <");
+               if(pShareInfo->GetPageTitle().GetLength() > 0)
+               {
+                       textVal.Append(L" <");
+               }
+               else
+               {
+                       textVal.Append(L"<");
+               }
                AppLog("share info url is %ls",pShareInfo->GetPageURL().GetPointer());
                textVal.Append(pShareInfo->GetPageURL().GetPointer());
                textVal.Append(L">");
        }
-       String typeKey = L"type";
-       String typeVal = L"SMS";
-       String textKey = L"text";
+       if (pShareInfo != null)
+       {
+               imageAttachment = pShareInfo->GetImageAttached();
+               if (imageAttachment)
+               {
+                       // type is mms
+                       typeVal = L"mms";
+                       attachVal = pShareInfo->GetImagePath();
+
+                       pDataList = new (std::nothrow) ArrayList();
+                       pDataList->Construct();
+                       pDataList->Add(&attachVal);
+               }
+               else
+               {
+                       typeVal = L"sms";
+                       // type is sms
+               }
+       }
+
        extraData.Add(&typeKey, &typeVal);
-       extraData.Add(&textKey, &textVal);
+
+       if (imageAttachment)
+       {
+               // type is MMMS, attach the image
+               extraData.Add(&attachKey, pDataList);
+       }
+       else
+       {
+               // type is SMS , attach the text
+               extraData.Add(&textKey, &textVal);
+       }
+
        AppControl* pAc = AppManager::FindAppControlN(L"tizen.messages", L"http://tizen.org/appcontrol/operation/compose");
        if (pAc)
        {
-               pAc->Start(null, null, &extraData, null);
+               r = pAc->Start(null, null, &extraData, this);
                delete pAc;
        }
+
        if (pShareInfo != null)
        {
                delete pShareInfo;
        }
-       
+       if(pDataList)
+       {
+               delete pDataList;
+       }
 }
 
 void
 SharePopup::OnAppControlCompleted(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId, const Tizen::Base::Collection::IList* pResultList)
 {
+       AppLog("InternetApp::OnForeground called");
+       Frame* pCurrentFrame = null;
+       pCurrentFrame =  Application::GetInstance()->GetAppFrame()->GetFrame();
+
+       if (pCurrentFrame != null)
+       {
+               pCurrentFrame->SetEnabled(true);
+               pCurrentFrame->Invalidate(true);
+       }
+}
+
+void SharePopup::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
+{
+       AppLog("SharePopup::OnAppControlCompleteResponseReceived");
+       Frame* pCurrentFrame = null;
+       pCurrentFrame =  Application::GetInstance()->GetAppFrame()->GetFrame();
+
+       if (pCurrentFrame != null)
+       {
+               pCurrentFrame->SetEnabled(true);
+               pCurrentFrame->Invalidate(true);
+       }
 
 }