devicemgmtdialogsplugin/src/devicemanagementnotifierutils.cpp
changeset 42 aa33c2cb9a50
parent 30 d3981f4fe6a4
child 52 6e38e48ee756
--- a/devicemgmtdialogsplugin/src/devicemanagementnotifierutils.cpp	Wed Jun 23 18:03:02 2010 +0300
+++ b/devicemgmtdialogsplugin/src/devicemanagementnotifierutils.cpp	Tue Jul 06 14:06:19 2010 +0300
@@ -82,6 +82,7 @@
 syncmlnotifier::syncmlnotifier(devicemanagementnotifierwidget* ptr)
     {
     iPtr = ptr;
+    mDefaultServerPkgZero = false;
     qDebug("devicemanagementnotifierutils syncmlnotifier");
     QTranslator *translator = new QTranslator();
     QString lang = QLocale::system().name();
@@ -111,15 +112,21 @@
     bool uiserverinteraction = false;
     bool serverpushinformativeenabled = false;
     bool serverpushinteractiveenabled = false;
-
+    bool scomonotifierenabled = false;
+    
     int profileid = 0;
     int uimode = 0;
 
     QString serverpushinformmessage;
     QString serverpushconfirmmessage;
-
+    QString appname = NULL;
+    QString size = NULL;
+    QString sizeformat = NULL;
+    QString data = NULL;
     QString serverdispname;
-
+    bool defaultprofile = false;
+	QString scomonotifiertype;
+    int timeout = 0;
     while (i != parameters.constEnd())
         {
         if (i.key().toAscii() == "profileid")
@@ -153,7 +160,35 @@
             {
             serverdispname = i.value().toString();
             }
-
+        
+        if (i.key().toAscii() == "fotadefaultprofile")
+            {
+            defaultprofile = i.value().toBool();
+            }
+        
+        if (i.key().toAscii()== "scomonotifier")
+            {
+            scomonotifierenabled = true;
+            scomonotifiertype = i.value().toString();
+            }
+        if (i.key().toAscii()=="scomoappdata")
+            {
+            //getting data for download failed cases
+            data = i.value().toString();
+            QStringList list1 = data.split(",");
+            appname = list1[0];
+            size =list1[1];
+            sizeformat = list1[2];
+            }
+        if(i.key().toAscii()=="scomoappname")
+            {
+            //getting app name for install and uninstall failed cases
+            appname = i.value().toString();
+            }
+        if (i.key().toAscii() == "pkgzerotimeout")
+            {
+            timeout = i.value().toInt();
+            }
         ++i;
         }
 
@@ -162,7 +197,8 @@
         qDebug("server interaction packet 0 enabled ");
         qDebug()<<EHbSOSNotifierKeyStatus;
         msymnotifier->setnotifierorigin(EHbSOSNotifierKeyStatus);
-        createserverinitnotifier(profileid, uimode, serverdispname);
+        createserverinitnotifier(profileid, uimode, serverdispname,
+                defaultprofile, timeout);
         }
     else if (serverpushinformativeenabled)
         {
@@ -178,11 +214,90 @@
          msymnotifier->setnotifierorigin(EHbDMSyncNotifierKeyStatus);
         createserveralertconfirmative(serverpushconfirmmessage);
         }
+    else if (scomonotifierenabled)
+        {
+        createscomonotifier(scomonotifiertype,appname,size,sizeformat);
+        }
 
     }
 
-void syncmlnotifier::createserverinitnotifier(int profileid, int uimode,
-        QString& servername)
+void syncmlnotifier::createscomonotifier(QString notifiertype,QString app_name,QString asize,QString format)
+    {
+    HbDocumentLoader loader;
+    bool ok = false;
+    loader.load(":/xml/resources/error_notes.docml", &ok);
+    if (!ok)
+        {
+        return;
+        }
+    QString val;
+    HbDialog* dialog = qobject_cast<HbDialog*> (loader.findWidget("dialog"));
+    HbLabel* label;
+
+    dialog->setTimeout(HbPopup::ContextMenuTimeout);
+
+    if (notifiertype == "installfailed")
+        {
+        //install failed case
+        label = qobject_cast<HbLabel*> (loader.findWidget("heading_text"));
+        val = hbTrId("txt_device_update_title_installation_failed");
+        label->setPlainText(val);
+        val = hbTrId("txt_device_update_info_installation_of_1_kb_failed").arg(
+                app_name);
+        label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
+        label->setPlainText(val);
+        }
+    else if (notifiertype == "downloadfailed")
+        {
+        //download failed
+        label = qobject_cast<HbLabel*> (loader.findWidget("heading_text"));
+        val = hbTrId("txt_device_update_title_downloading_failed");
+
+        label->setPlainText(val);
+        int sizfor = -1;
+        format == QString("kb") ? sizfor = 0 : sizfor = 1;
+        format == QString("mb") ? sizfor = 1 : sizfor = 2;
+        switch (sizfor)
+            {
+            case 0:
+                val
+                        = hbTrId(
+                                "txt_device_update_info_downloading_of_1_Kb_failed").arg(
+                                app_name, asize);
+                break;
+            case 1:
+                val
+                        = hbTrId(
+                                "txt_device_update_info_downloading_of_1_Mb_failed").arg(
+                                app_name, asize);
+                break;
+            default:
+                val
+                        = hbTrId(
+                                "txt_device_update_info_downloading_of_1_Gb_failed").arg(
+                                app_name, asize);
+                break;
+            }
+        label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
+        label->setPlainText(val);
+        }
+    else
+        {
+        //uninstall failed
+        label = qobject_cast<HbLabel*> (loader.findWidget("heading_text"));
+        val = hbTrId("txt_device_update_title_Uninstallation_failed");
+        label->setPlainText(val);
+        val = hbTrId("txt_device_update_info_uninstalling_of_1_Mb_failed").arg(
+                app_name, asize);
+
+        label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
+        label->setPlainText(val);
+        }
+    dialog->setTimeout(HbPopup::StandardTimeout);
+    dialog->show();
+    }
+void syncmlnotifier::createserverinitnotifier(int& profileid, int& uimode,
+        QString& servername, bool& defaultprofile, int& timeout)
     {
     
     int inittype = msymnotifier->serverinittype(uimode);
@@ -209,29 +324,48 @@
         //set heading content
         HbLabel *contentheading = qobject_cast<HbLabel *> (loader.findWidget(
                 "qtl_dialog_pri_heading"));
-        QString heading = hbTrId("txt_device_update_title_update_available");
-        contentheading->setPlainText(heading);
-
+        QString heading;        
         //set body content
         HbLabel *contentbody = qobject_cast<HbLabel *> (loader.findWidget(
                 "qtl_dialog_pri5"));
-        QString serverinitmessage = hbTrId(
-                "txt_device_update_info_recommended_update_is_avail").arg(
-                servername);
+        QString serverinitmessage;
+        QString softkeyok;
+        QString softkeyCancel;
+        if(defaultprofile)
+            {
+            mDefaultServerPkgZero = true;	
+            heading = hbTrId("txt_device_update_title_update_available");
+            serverinitmessage = 
+              hbTrId("txt_device_update_info_recommended_update_is_avail").arg(
+                            servername);
+            softkeyok = hbTrId("txt_device_update_button_update");
+            softkeyCancel = hbTrId("txt_device_update_button_later");                 
+            }
+        else
+            {
+            mDefaultServerPkgZero = false;	
+            heading = hbTrId("txt_device_update_title_service_recomended");
+            serverinitmessage = 
+              hbTrId("txt_device_update_info_1_recommends_a_service_for").arg(
+                            servername);
+            softkeyok = hbTrId("txt_common_button_ok");
+            softkeyCancel = hbTrId("txt_common_button_cancel");                            
+            }
+        contentheading->setPlainText(heading);
         contentbody->setPlainText(serverinitmessage);
 
         //set softkeys
         HbAction *primaryAction = (HbAction *) dialog->actions().first();
-        QString softkeyok = hbTrId("txt_common_button_ok");
+        
         primaryAction->setText(softkeyok);
 
         HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
-        QString softkeyCancel = hbTrId("txt_common_button_cancel");
+        
         secondaryAction->setText(softkeyCancel);
 
         //set dialog properties
-        dialog->setTimeout(HbPopup::NoTimeout);
-
+        dialog->setTimeout(timeout);
+        dialog->setDismissPolicy(HbPopup::NoDismiss);
         //load appropriate icon from svg file
         HbLabel* label1 = qobject_cast<HbLabel*> (loader.findWidget("icon"));
         HbIcon* icon1 = new HbIcon(":/devman_icon/resources/iconnotifier.svg");
@@ -240,6 +374,8 @@
         //label1->setState(QIcon::Off);
         label1->setToolTip("Mode=Normal, State=Off");
 
+        QObject::connect(dialog, SIGNAL(finished(HbAction*)), 
+                this, SLOT(noteTimedOut(HbAction*)));
         QObject::connect(primaryAction, SIGNAL(triggered()), this,
                 SLOT(okSelected()));
 
@@ -268,7 +404,7 @@
                 "qtl_dialog_pri5"));
 
         QString serverinitmessage = hbTrId(
-                "txt_device_update_info_update_serverpush_informative").arg(
+                "txt_deviceupdate_info_updating_device_from_server").arg(
                 servername);
 
         //getserverspecifictexttodisplay(profileid, uimode, serverinitmessage);
@@ -397,6 +533,22 @@
     
     }
 
+void syncmlnotifier::noteTimedOut(HbAction* action)
+    {
+    qDebug("Pkg zero note timed out");
+    if (action == NULL)
+        {
+        int timeout = -33; //KErrTimedOut
+        msymnotifier->setstatus(timeout);
+        if(mDefaultServerPkgZero) //For default server action is RSK
+        iPtr->dmDevdialogDismissed(
+                devicemanagementnotifierwidget::EServerAlertNote, -3);
+        else //For Non default server action is LSK
+        iPtr->dmDevdialogDismissed(
+                devicemanagementnotifierwidget::EServerAlertNote, 0);	        	
+        }
+    }
+
 syncmlnotifier::~syncmlnotifier()
     {
     qDebug("syncmlnotifier::~syncmlnotifier");