messagingapp/shareui/src/shareuiprivate.cpp
changeset 48 4f501b74aeb1
parent 38 4e4b6adb1024
child 51 3507212d340e
equal deleted inserted replaced
46:b1f0785c289d 48:4f501b74aeb1
    29 #include <HbListView>
    29 #include <HbListView>
    30 #include <HbListViewItem>
    30 #include <HbListViewItem>
    31 #include <HbNotificationDialog>
    31 #include <HbNotificationDialog>
    32 #include <HbIconItem>
    32 #include <HbIconItem>
    33 #include <HbTextItem>
    33 #include <HbTextItem>
    34 
    34 #include <HbColorScheme>
    35 #include <xqserviceglobal.h>
    35 #include <xqserviceglobal.h>
    36 #include <xqaiwrequest.h>
    36 #include <xqaiwrequest.h>
    37 #include <xqaiwinterfacedescriptor.h>
    37 #include <xqaiwinterfacedescriptor.h>
    38 
    38 
    39 // USER INCLUDES
    39 // USER INCLUDES
    52 #define LOC_NO_SERVICES         hbTrId("No services found.")
    52 #define LOC_NO_SERVICES         hbTrId("No services found.")
    53 #define LOC_NO_FILES            hbTrId("No files found.")
    53 #define LOC_NO_FILES            hbTrId("No files found.")
    54 #define LOC_SERVICE_ERROR       hbTrId("Service error.")
    54 #define LOC_SERVICE_ERROR       hbTrId("Service error.")
    55 #define LOC_PROTECTED_CONTENT   hbTrId("Protected content.")
    55 #define LOC_PROTECTED_CONTENT   hbTrId("Protected content.")
    56 
    56 
       
    57 const QString LIST_ITEM_TITLE("qtc_list_item_title_normal");
       
    58 
    57 /**
    59 /**
    58  * Constructor.
    60  * Constructor.
    59  */
    61  */
    60 ShareUiPrivate::ShareUiPrivate()
    62 ShareUiPrivate::ShareUiPrivate()
    61     {
    63     {
    82     foreach(XQAiwRequest* request,mAiwRequestList)
    84     foreach(XQAiwRequest* request,mAiwRequestList)
    83     {
    85     {
    84         delete request;
    86         delete request;
    85     }
    87     }
    86     mAiwRequestList.clear();
    88     mAiwRequestList.clear();
    87 
    89     mServiceInterfaceMap.clear();
    88     }
    90     }
    89 
    91 
    90 /**
    92 /**
    91  * Initialize and start the dialog
    93  * Initialize and start the dialog
    92  * 
    94  * 
    93  * @param fileList list of tokens that would allow file manipulation.
    95  * @param fileList list of tokens that would allow file manipulation.
    94  * @return bool error false if dialog initialization failed, true otherwise.
    96  * @return bool error false if dialog initialization failed, true otherwise.
    95  * 
    97  * 
    96  */
    98  */
    97 bool ShareUiPrivate::init(QStringList& fileList, bool embedded)
    99 bool ShareUiPrivate::init(QStringList& fileList, bool embedded)
    98     {    
   100     {
    99     reset();
   101     reset();
   100     mIsEmbedded = embedded;
   102     mIsEmbedded = embedded;
   101     // No input files
   103     // No input files
   102     if ( fileList.count() == 0 )
   104     if (fileList.count() == 0) {
   103         {
       
   104         showNote(LOC_NO_FILES);
   105         showNote(LOC_NO_FILES);
   105         return true;       
   106         return true;
   106         }
   107     }
   107 
   108 
   108 #ifdef __SHAREUI_MIME_HANDLING__   
   109 #ifdef __SHAREUI_MIME_HANDLING__   
   109     // Get the file attributes (MIME and forward lock)
   110     // Get the file attributes (MIME and forward lock)
   110     QStringList mimeTypeList;
   111     QStringList mimeTypeList;
   111     QStringList forwardStatusList;
   112     QStringList forwardStatusList;
   112     getFileAttributes(fileList, mimeTypeList, forwardStatusList);
   113     getFileAttributes(fileList, mimeTypeList, forwardStatusList);
   113     
   114 
   114     // Ignore protected files
   115     // Ignore protected files
   115     QStringList filteredFileList;
   116     QStringList filteredFileList;
   116     QStringList filteredMimeList;
   117     QStringList filteredMimeList;
   117     for ( int i = 0; i < forwardStatusList.count(); i++ )
   118     for (int i = 0; i < forwardStatusList.count(); i++) {
   118         {
   119         if (forwardStatusList[i].toInt()) {
   119         if ( forwardStatusList[i].toInt() )
       
   120             {
       
   121             filteredFileList << fileList[i];
   120             filteredFileList << fileList[i];
   122             filteredMimeList << mimeTypeList[i];
   121             filteredMimeList << mimeTypeList[i];
   123             }
   122         }
   124         }
   123     }
   125     filteredMimeList.removeDuplicates();    
   124     filteredMimeList.removeDuplicates();
   126     
   125 
   127     // Some protected content
   126     // Some protected content
   128     if ( fileList.count() != filteredFileList.count() )
   127     if (fileList.count() != filteredFileList.count()) {
   129         {
   128         showNote(LOC_PROTECTED_CONTENT);
   130         showNote(LOC_PROTECTED_CONTENT);      
       
   131         return true;
   129         return true;
   132         }
   130     }
   133     
   131 
   134     // Only protected content
   132     // Only protected content
   135     if ( filteredFileList.count() == 0 )
   133     if (filteredFileList.count() == 0) {
   136         {
       
   137         showNote(LOC_NO_FILES);
   134         showNote(LOC_NO_FILES);
   138         return true;       
   135         return true;
   139         }
   136     }
   140 #endif
   137 #endif
   141 
   138 
   142 #ifdef __SHAREUI_MIME_HANDLING__ 
   139 #ifdef __SHAREUI_MIME_HANDLING__ 
   143     for ( int i = 0; i < filteredFileList.count(); i++ )
   140     for (int i = 0; i < filteredFileList.count(); i++) {
   144         {     
       
   145         mFileList.append(QDir::toNativeSeparators(filteredFileList[i]));
   141         mFileList.append(QDir::toNativeSeparators(filteredFileList[i]));
   146         }
   142     }
   147 #else
   143 #else
   148     for ( int i = 0; i < fileList.count(); i++ )
   144     for ( int i = 0; i < fileList.count(); i++ )
   149         {     
   145     {
   150         mFileList.append(QDir::toNativeSeparators(fileList[i]));
   146         mFileList.append(QDir::toNativeSeparators(fileList[i]));
   151         }
   147     }
   152 #endif
   148 #endif
   153     
   149 
   154     QList<XQAiwInterfaceDescriptor> serviceDescriptorList = 
   150     QList<XQAiwInterfaceDescriptor> serviceDescriptorList = mAppManager.list(SERVICE_INTERFACE,
   155             mAppManager.list(SERVICE_INTERFACE, SHARE_OP);
   151         SHARE_OP);
   156     if ( serviceDescriptorList.size() > 0 )
   152 
   157         {          
   153     if (serviceDescriptorList.size() > 0) {
   158         initializeUi();
   154         initializeUi();
   159 
   155         //sorting the services based on service names,
   160         for ( int i = 0; i < serviceDescriptorList.count() ; i++ )
   156         //reinserting sorted list into serviceDescriptorList
   161             { 
   157         for (int i = 0; i < serviceDescriptorList.count(); i++) {
       
   158             mServiceInterfaceMap.insert(serviceDescriptorList[i].serviceName(),
       
   159                 serviceDescriptorList[i]);
       
   160         }
       
   161         QStringList serviceNames = mServiceInterfaceMap.keys();
       
   162         serviceNames.sort();
       
   163         serviceDescriptorList.clear();
       
   164         for (int i = 0; i < serviceNames.count(); i++) {
       
   165             serviceDescriptorList.append(mServiceInterfaceMap.value(serviceNames.at(i)));
       
   166         }
       
   167         for (int i = 0; i < serviceDescriptorList.count(); i++) {
   162 #ifdef __SHAREUI_MIME_HANDLING__          
   168 #ifdef __SHAREUI_MIME_HANDLING__          
   163             // Filter services based on content type
   169             // Filter services based on content type
   164             QString allowedTypes = serviceDescriptorList[i].customProperty
   170             QString allowedTypes = serviceDescriptorList[i].customProperty(QString(
   165                     (QString("allowed_mime_types"));              
   171                 "allowed_mime_types"));
   166             QString blockedTypes = serviceDescriptorList[i].customProperty
   172             QString blockedTypes = serviceDescriptorList[i].customProperty(QString(
   167                     (QString("blocked_mime_types"));
   173                 "blocked_mime_types"));
   168             
   174 
   169             // Check against MIME filters
   175             // Check against MIME filters
   170             if ( ! isContentAllowed( filteredMimeList, allowedTypes ) )
   176             if (!isContentAllowed(filteredMimeList, allowedTypes))
   171                 continue;
   177                 continue;
   172             
   178 
   173             if ( isContentBlocked( filteredMimeList, blockedTypes ) )
   179             if (isContentBlocked(filteredMimeList, blockedTypes))
   174                 continue;                     
   180                 continue;
   175 #endif            
   181 #endif            
   176             HbAction* action = fetchServiceAction(serviceDescriptorList[i]);
   182             HbAction* action = fetchServiceAction(serviceDescriptorList[i]);
   177             QString iconName = serviceDescriptorList[i].customProperty
   183             QString iconName = serviceDescriptorList[i].customProperty(QString("aiw_action_icon"));
   178                     (QString("aiw_action_icon"));
   184             if (action) {
   179             if ( action )
       
   180                 {
       
   181                 updateShareUiDialogList(action, iconName);
   185                 updateShareUiDialogList(action, iconName);
   182                 }
   186             }
   183             }
   187         }
   184         
   188         if (mContentItemModel->rowCount() == 0) {
   185         if ( mContentItemModel->rowCount() == 0 )
       
   186             {
       
   187             showNote(LOC_NO_SERVICES);
   189             showNote(LOC_NO_SERVICES);
   188             return true;
   190             return true;
   189             }
   191         }
   190 
   192 
   191         mSharePopup->show();
   193         mSharePopup->show();
   192         }
   194     }
   193     else
   195     else {
   194         {
       
   195         showNote(LOC_NO_SERVICES);
   196         showNote(LOC_NO_SERVICES);
   196         }
   197     }
   197     
   198 
   198     return true;
   199     return true;
   199     }
   200     }
   200 
   201 
   201 /**
   202 /**
   202   * Creates the view for the share ui.
   203   * Creates the view for the share ui.
   206     // Dialog
   207     // Dialog
   207     mSharePopup = new HbDialog();
   208     mSharePopup = new HbDialog();
   208     // make it delete itself on close
   209     // make it delete itself on close
   209     mSharePopup->setAttribute( Qt::WA_DeleteOnClose, true );
   210     mSharePopup->setAttribute( Qt::WA_DeleteOnClose, true );
   210     HbTextItem* heading = new HbTextItem(LOC_SEND_SELECTED_ITEM, mSharePopup);
   211     HbTextItem* heading = new HbTextItem(LOC_SEND_SELECTED_ITEM, mSharePopup);
       
   212     QColor color = HbColorScheme::color( LIST_ITEM_TITLE );
       
   213     heading->setTextColor( color );
   211     heading->setAlignment(Qt::AlignCenter);
   214     heading->setAlignment(Qt::AlignCenter);
   212     mSharePopup->setDismissPolicy(HbDialog::TapAnywhere);
   215     mSharePopup->setDismissPolicy(HbDialog::TapAnywhere);
   213     mSharePopup->setHeadingWidget(heading);
   216     mSharePopup->setHeadingWidget(heading);
   214     mSharePopup->setFrameType(HbDialog::Strong);
   217     mSharePopup->setFrameType(HbDialog::Strong);
   215     connect(mSharePopup, SIGNAL(aboutToClose()), this, SLOT(reset()));
   218     connect(mSharePopup, SIGNAL(aboutToClose()), this, SLOT(reset()));
   484 void ShareUiPrivate::showNote(QString text)
   487 void ShareUiPrivate::showNote(QString text)
   485     {
   488     {
   486     HbNotificationDialog* dlg = new HbNotificationDialog();
   489     HbNotificationDialog* dlg = new HbNotificationDialog();
   487     dlg->setFocusPolicy(Qt::NoFocus);
   490     dlg->setFocusPolicy(Qt::NoFocus);
   488     dlg->setAttribute(Qt::WA_DeleteOnClose, true);
   491     dlg->setAttribute(Qt::WA_DeleteOnClose, true);
   489     dlg->setText(text);
   492     dlg->setTitle(text);
   490     dlg->show();
   493     dlg->show();
   491     }
   494     }
   492 
   495 
   493 /**
   496 /**
   494  * List item prototype constructor.
   497  * List item prototype constructor.