Fixed Nabi Issues N_SE-52525,52761,52458,52443,52423,52179,52389 and third party...
[apps/osp/Internet.git] / src / IntSharePopup.cpp
index b5eaef2..fa5844d 100644 (file)
@@ -145,6 +145,9 @@ SharePopup::~SharePopup(void)
                __pShareList->RemoveAll(true);
        }
 
+       if(__pAppControlList)
+               __pAppControlList->RemoveAll(true);
+       delete __pAppControlList;
 }
 
 bool
@@ -166,6 +169,7 @@ SharePopup::Initialize(void)
 
        __pList->SetItemProvider(*this);
        __pList->AddListViewItemEventListener(*this);
+//     __pList->SetTextOfEmptyList(L"No Sharing Options");//hardcoded string
 
        pCancelButton = static_cast< Button* >(GetControl(L"IDC_BUTTON1", true));
        if (pCancelButton)
@@ -229,6 +233,11 @@ SharePopup::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView,
                        __appControlOngoing = true;
                        // share via message
                        StartMessageAppControl();
+                       if(__pTimer == null)
+                       {
+                               __pTimer = new(std::nothrow) Timer();
+                               __pTimer->Construct(*this);
+                       }
                        __pTimer->Start(2500);
                }
        }
@@ -240,14 +249,38 @@ SharePopup::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView,
                        __appControlOngoing = true;
                        // share via email
                        StartEmailAppControl();
+                       if(__pTimer == null)
+                       {
+                               __pTimer = new(std::nothrow) Timer();
+                               __pTimer->Construct(*this);
+                       }
                        __pTimer->Start(2500);
                }
 
        }
        break;
        default:
+               if(__appControlOngoing == false)
+               {
+                       __appControlOngoing = true;
+                       //share via third party app
+                       StartAppControl(index);
+                       if(__pTimer == null)
+                       {
+                               __pTimer = new(std::nothrow) Timer();
+                               __pTimer->Construct(*this);
+                       }
+                       __pTimer->Start(2500);
+               }
                break;
        }
+       Frame* pCurrentFrame = null;
+       pCurrentFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
+
+       if (pCurrentFrame != null)
+       {
+               pCurrentFrame->SetEnabled(false);
+       }
 }
 
 void
@@ -265,6 +298,7 @@ SharePopup::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, i
 Tizen::Ui::Controls::ListItemBase*
 SharePopup::CreateItem(int index, int itemWidth)
 {
+       AppLog("SharePopup::CreateItem index %d",index);
        result r = E_FAILURE;
        ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
        int textSize = 35;
@@ -280,6 +314,8 @@ SharePopup::CreateItem(int index, int itemWidth)
                return null;
        }
 
+
+
        switch(index)
        {
        case 0:
@@ -297,6 +333,13 @@ SharePopup::CreateItem(int index, int itemWidth)
        }
        break;
        default:
+               if(__pAppControlList)
+               {
+                       AppControl * pControl = dynamic_cast<AppControl*>(__pAppControlList->GetAt(index -2));
+                       AppLog("SharePopup::CreateItem appcontrol count %d",__pAppControlList->GetCount());
+                       if(pControl)
+                               pItem->AddElement(Rectangle(45,0, GetClientAreaBounds().width, listItemHeight), ID_FORMAT_MESSAGE_STRING+index, pControl->GetAppName(), true);
+               }
                break;
        }
        return pItem;
@@ -311,7 +354,30 @@ SharePopup::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int
 int
 SharePopup::GetItemCount(void)
 {
-       return 2;
+       String* pStrId = new String(L"http://tizen.org/appcontrol/operation/share_text");
+       __pAppControlList = AppManager::FindAppControlsN(pStrId,null,null,null);
+       if(__pAppControlList == null)
+       {
+               return 2;
+       }
+       int count = __pAppControlList->GetCount();
+       AppLog("SharePopup::GetItemCount appcontrol count %d",count);
+       int removeCount = 0;
+       for(int pos = 0; pos < count; pos++)
+       {
+               AppControl * pControl = dynamic_cast<AppControl*>(__pAppControlList->GetAt(pos));
+               if(pControl->GetAppName().Equals(L"Messages",false) == true || pControl->GetAppName().Equals(L"Email",false) == true )
+               {
+                       __pAppControlList->RemoveAt(pos,true);
+                       pos--;
+                       count --;
+                       removeCount++;
+               }
+       }
+
+       AppLog("removeCount %d",removeCount);
+       return count+removeCount;
+
 }
 
 result
@@ -331,6 +397,83 @@ void SharePopup::RemoveAllShareInfo()
        __pShareList->RemoveAll();
 }
 
+
+
+
+void
+SharePopup::StartAppControl(int index)
+{
+   HashMap extraData;
+   ShareInfo* pShareInfo = null;
+   result r = E_FAILURE;
+   bool imageAttachment = false;
+
+   extraData.Construct();
+
+   if (__pShareList != null)
+       {
+               pShareInfo = dynamic_cast<ShareInfo*>(__pShareList->GetAt(0));
+               if (pShareInfo != null)
+               {
+                       String testURL = pShareInfo->GetPageURL();
+                       AppLogDebug("getpageURL getpageURL is %ls", testURL.GetPointer());
+               }
+       }
+
+   String textVal;
+
+       if (pShareInfo != null)
+       {
+               textVal.Append(pShareInfo->GetPageTitle());
+               textVal.Append(L" <");
+               AppLog("share info url is %ls",pShareInfo->GetPageURL().GetPointer());
+               textVal.Append(pShareInfo->GetPageURL().GetPointer());
+               textVal.Append(L">");
+       }
+
+
+   String textKey = L"http://tizen.org/appcontrol/data/text";
+
+   //String attachKey = L"attachments";
+   String attachKey = L"http://tizen.org/appcontrol/data/path";
+   String attachVal;
+       if (pShareInfo != null)
+       {
+               imageAttachment = pShareInfo->GetImageAttached();
+               if (imageAttachment)
+               {
+                       attachVal = pShareInfo->GetImagePath();
+                       AppLog("SharePopup::StartEmailAppControl imagePath is %S",attachVal.GetPointer());
+               }
+               else
+               {
+                        attachVal = L"";
+               }
+       }
+
+       ArrayList* pDataList = null;
+       pDataList = new (std::nothrow) ArrayList();
+       pDataList->Construct();
+       pDataList->Add(&attachVal);
+
+
+   extraData.Add(&textKey, &textVal);
+
+   if(attachVal.GetLength() > 0)
+   {
+          extraData.Add(&attachKey, pDataList);
+   }
+
+   AppControl * pControl = dynamic_cast<AppControl*>(__pAppControlList->GetAt(index - 2));
+   if (pControl)
+   {
+         r = pControl->Start(null, null, &extraData, this);
+//        delete pControl;
+   }
+
+   delete pDataList;
+}
+
 void
 SharePopup::StartEmailAppControl(void)
 {
@@ -557,6 +700,13 @@ void SharePopup::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& a
        }
        Popup::SetShowState(false);
        Popup::Show();
+       Frame* pCurrentFrame = null;
+       pCurrentFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
+
+       if (pCurrentFrame != null)
+       {
+               pCurrentFrame->SetEnabled(true);
+       }
        __appControlOngoing = false;
 }