devicemgmtdialogsplugin/src/devicemanagementnotifierutils.cpp
changeset 42 aa33c2cb9a50
parent 30 d3981f4fe6a4
child 52 6e38e48ee756
equal deleted inserted replaced
41:c742e1129640 42:aa33c2cb9a50
    80     }
    80     }
    81 
    81 
    82 syncmlnotifier::syncmlnotifier(devicemanagementnotifierwidget* ptr)
    82 syncmlnotifier::syncmlnotifier(devicemanagementnotifierwidget* ptr)
    83     {
    83     {
    84     iPtr = ptr;
    84     iPtr = ptr;
       
    85     mDefaultServerPkgZero = false;
    85     qDebug("devicemanagementnotifierutils syncmlnotifier");
    86     qDebug("devicemanagementnotifierutils syncmlnotifier");
    86     QTranslator *translator = new QTranslator();
    87     QTranslator *translator = new QTranslator();
    87     QString lang = QLocale::system().name();
    88     QString lang = QLocale::system().name();
    88     QString path = "Z:/resource/qt/translations/";
    89     QString path = "Z:/resource/qt/translations/";
    89     bool fine = translator->load("deviceupdates_en.qm", path);
    90     bool fine = translator->load("deviceupdates_en.qm", path);
   109 
   110 
   110     bool profileidenabled = false;
   111     bool profileidenabled = false;
   111     bool uiserverinteraction = false;
   112     bool uiserverinteraction = false;
   112     bool serverpushinformativeenabled = false;
   113     bool serverpushinformativeenabled = false;
   113     bool serverpushinteractiveenabled = false;
   114     bool serverpushinteractiveenabled = false;
   114 
   115     bool scomonotifierenabled = false;
       
   116     
   115     int profileid = 0;
   117     int profileid = 0;
   116     int uimode = 0;
   118     int uimode = 0;
   117 
   119 
   118     QString serverpushinformmessage;
   120     QString serverpushinformmessage;
   119     QString serverpushconfirmmessage;
   121     QString serverpushconfirmmessage;
   120 
   122     QString appname = NULL;
       
   123     QString size = NULL;
       
   124     QString sizeformat = NULL;
       
   125     QString data = NULL;
   121     QString serverdispname;
   126     QString serverdispname;
   122 
   127     bool defaultprofile = false;
       
   128 	QString scomonotifiertype;
       
   129     int timeout = 0;
   123     while (i != parameters.constEnd())
   130     while (i != parameters.constEnd())
   124         {
   131         {
   125         if (i.key().toAscii() == "profileid")
   132         if (i.key().toAscii() == "profileid")
   126             {
   133             {
   127 
   134 
   151 
   158 
   152         if (i.key().toAscii() == "serverdisplayname")
   159         if (i.key().toAscii() == "serverdisplayname")
   153             {
   160             {
   154             serverdispname = i.value().toString();
   161             serverdispname = i.value().toString();
   155             }
   162             }
   156 
   163         
       
   164         if (i.key().toAscii() == "fotadefaultprofile")
       
   165             {
       
   166             defaultprofile = i.value().toBool();
       
   167             }
       
   168         
       
   169         if (i.key().toAscii()== "scomonotifier")
       
   170             {
       
   171             scomonotifierenabled = true;
       
   172             scomonotifiertype = i.value().toString();
       
   173             }
       
   174         if (i.key().toAscii()=="scomoappdata")
       
   175             {
       
   176             //getting data for download failed cases
       
   177             data = i.value().toString();
       
   178             QStringList list1 = data.split(",");
       
   179             appname = list1[0];
       
   180             size =list1[1];
       
   181             sizeformat = list1[2];
       
   182             }
       
   183         if(i.key().toAscii()=="scomoappname")
       
   184             {
       
   185             //getting app name for install and uninstall failed cases
       
   186             appname = i.value().toString();
       
   187             }
       
   188         if (i.key().toAscii() == "pkgzerotimeout")
       
   189             {
       
   190             timeout = i.value().toInt();
       
   191             }
   157         ++i;
   192         ++i;
   158         }
   193         }
   159 
   194 
   160     if (profileidenabled && uiserverinteraction)
   195     if (profileidenabled && uiserverinteraction)
   161         {
   196         {
   162         qDebug("server interaction packet 0 enabled ");
   197         qDebug("server interaction packet 0 enabled ");
   163         qDebug()<<EHbSOSNotifierKeyStatus;
   198         qDebug()<<EHbSOSNotifierKeyStatus;
   164         msymnotifier->setnotifierorigin(EHbSOSNotifierKeyStatus);
   199         msymnotifier->setnotifierorigin(EHbSOSNotifierKeyStatus);
   165         createserverinitnotifier(profileid, uimode, serverdispname);
   200         createserverinitnotifier(profileid, uimode, serverdispname,
       
   201                 defaultprofile, timeout);
   166         }
   202         }
   167     else if (serverpushinformativeenabled)
   203     else if (serverpushinformativeenabled)
   168         {
   204         {
   169         qDebug("server push informative enabled ");
   205         qDebug("server push informative enabled ");
   170         qDebug()<<EHbDMSyncNotifierKeyStatus;
   206         qDebug()<<EHbDMSyncNotifierKeyStatus;
   176         qDebug("server push informative enabled ");
   212         qDebug("server push informative enabled ");
   177         qDebug()<<EHbDMSyncNotifierKeyStatus;
   213         qDebug()<<EHbDMSyncNotifierKeyStatus;
   178          msymnotifier->setnotifierorigin(EHbDMSyncNotifierKeyStatus);
   214          msymnotifier->setnotifierorigin(EHbDMSyncNotifierKeyStatus);
   179         createserveralertconfirmative(serverpushconfirmmessage);
   215         createserveralertconfirmative(serverpushconfirmmessage);
   180         }
   216         }
   181 
   217     else if (scomonotifierenabled)
   182     }
   218         {
   183 
   219         createscomonotifier(scomonotifiertype,appname,size,sizeformat);
   184 void syncmlnotifier::createserverinitnotifier(int profileid, int uimode,
   220         }
   185         QString& servername)
   221 
       
   222     }
       
   223 
       
   224 void syncmlnotifier::createscomonotifier(QString notifiertype,QString app_name,QString asize,QString format)
       
   225     {
       
   226     HbDocumentLoader loader;
       
   227     bool ok = false;
       
   228     loader.load(":/xml/resources/error_notes.docml", &ok);
       
   229     if (!ok)
       
   230         {
       
   231         return;
       
   232         }
       
   233     QString val;
       
   234     HbDialog* dialog = qobject_cast<HbDialog*> (loader.findWidget("dialog"));
       
   235     HbLabel* label;
       
   236 
       
   237     dialog->setTimeout(HbPopup::ContextMenuTimeout);
       
   238 
       
   239     if (notifiertype == "installfailed")
       
   240         {
       
   241         //install failed case
       
   242         label = qobject_cast<HbLabel*> (loader.findWidget("heading_text"));
       
   243         val = hbTrId("txt_device_update_title_installation_failed");
       
   244         label->setPlainText(val);
       
   245         val = hbTrId("txt_device_update_info_installation_of_1_kb_failed").arg(
       
   246                 app_name);
       
   247         label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
       
   248         label->setPlainText(val);
       
   249         }
       
   250     else if (notifiertype == "downloadfailed")
       
   251         {
       
   252         //download failed
       
   253         label = qobject_cast<HbLabel*> (loader.findWidget("heading_text"));
       
   254         val = hbTrId("txt_device_update_title_downloading_failed");
       
   255 
       
   256         label->setPlainText(val);
       
   257         int sizfor = -1;
       
   258         format == QString("kb") ? sizfor = 0 : sizfor = 1;
       
   259         format == QString("mb") ? sizfor = 1 : sizfor = 2;
       
   260         switch (sizfor)
       
   261             {
       
   262             case 0:
       
   263                 val
       
   264                         = hbTrId(
       
   265                                 "txt_device_update_info_downloading_of_1_Kb_failed").arg(
       
   266                                 app_name, asize);
       
   267                 break;
       
   268             case 1:
       
   269                 val
       
   270                         = hbTrId(
       
   271                                 "txt_device_update_info_downloading_of_1_Mb_failed").arg(
       
   272                                 app_name, asize);
       
   273                 break;
       
   274             default:
       
   275                 val
       
   276                         = hbTrId(
       
   277                                 "txt_device_update_info_downloading_of_1_Gb_failed").arg(
       
   278                                 app_name, asize);
       
   279                 break;
       
   280             }
       
   281         label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
       
   282         label->setPlainText(val);
       
   283         }
       
   284     else
       
   285         {
       
   286         //uninstall failed
       
   287         label = qobject_cast<HbLabel*> (loader.findWidget("heading_text"));
       
   288         val = hbTrId("txt_device_update_title_Uninstallation_failed");
       
   289         label->setPlainText(val);
       
   290         val = hbTrId("txt_device_update_info_uninstalling_of_1_Mb_failed").arg(
       
   291                 app_name, asize);
       
   292 
       
   293         label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
       
   294         label->setPlainText(val);
       
   295         }
       
   296     dialog->setTimeout(HbPopup::StandardTimeout);
       
   297     dialog->show();
       
   298     }
       
   299 void syncmlnotifier::createserverinitnotifier(int& profileid, int& uimode,
       
   300         QString& servername, bool& defaultprofile, int& timeout)
   186     {
   301     {
   187     
   302     
   188     int inittype = msymnotifier->serverinittype(uimode);
   303     int inittype = msymnotifier->serverinittype(uimode);
   189     qDebug("Notification type");
   304     qDebug("Notification type");
   190     qDebug()<<inittype;
   305     qDebug()<<inittype;
   207                 "dialog"));
   322                 "dialog"));
   208 
   323 
   209         //set heading content
   324         //set heading content
   210         HbLabel *contentheading = qobject_cast<HbLabel *> (loader.findWidget(
   325         HbLabel *contentheading = qobject_cast<HbLabel *> (loader.findWidget(
   211                 "qtl_dialog_pri_heading"));
   326                 "qtl_dialog_pri_heading"));
   212         QString heading = hbTrId("txt_device_update_title_update_available");
   327         QString heading;        
   213         contentheading->setPlainText(heading);
       
   214 
       
   215         //set body content
   328         //set body content
   216         HbLabel *contentbody = qobject_cast<HbLabel *> (loader.findWidget(
   329         HbLabel *contentbody = qobject_cast<HbLabel *> (loader.findWidget(
   217                 "qtl_dialog_pri5"));
   330                 "qtl_dialog_pri5"));
   218         QString serverinitmessage = hbTrId(
   331         QString serverinitmessage;
   219                 "txt_device_update_info_recommended_update_is_avail").arg(
   332         QString softkeyok;
   220                 servername);
   333         QString softkeyCancel;
       
   334         if(defaultprofile)
       
   335             {
       
   336             mDefaultServerPkgZero = true;	
       
   337             heading = hbTrId("txt_device_update_title_update_available");
       
   338             serverinitmessage = 
       
   339               hbTrId("txt_device_update_info_recommended_update_is_avail").arg(
       
   340                             servername);
       
   341             softkeyok = hbTrId("txt_device_update_button_update");
       
   342             softkeyCancel = hbTrId("txt_device_update_button_later");                 
       
   343             }
       
   344         else
       
   345             {
       
   346             mDefaultServerPkgZero = false;	
       
   347             heading = hbTrId("txt_device_update_title_service_recomended");
       
   348             serverinitmessage = 
       
   349               hbTrId("txt_device_update_info_1_recommends_a_service_for").arg(
       
   350                             servername);
       
   351             softkeyok = hbTrId("txt_common_button_ok");
       
   352             softkeyCancel = hbTrId("txt_common_button_cancel");                            
       
   353             }
       
   354         contentheading->setPlainText(heading);
   221         contentbody->setPlainText(serverinitmessage);
   355         contentbody->setPlainText(serverinitmessage);
   222 
   356 
   223         //set softkeys
   357         //set softkeys
   224         HbAction *primaryAction = (HbAction *) dialog->actions().first();
   358         HbAction *primaryAction = (HbAction *) dialog->actions().first();
   225         QString softkeyok = hbTrId("txt_common_button_ok");
   359         
   226         primaryAction->setText(softkeyok);
   360         primaryAction->setText(softkeyok);
   227 
   361 
   228         HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
   362         HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
   229         QString softkeyCancel = hbTrId("txt_common_button_cancel");
   363         
   230         secondaryAction->setText(softkeyCancel);
   364         secondaryAction->setText(softkeyCancel);
   231 
   365 
   232         //set dialog properties
   366         //set dialog properties
   233         dialog->setTimeout(HbPopup::NoTimeout);
   367         dialog->setTimeout(timeout);
   234 
   368         dialog->setDismissPolicy(HbPopup::NoDismiss);
   235         //load appropriate icon from svg file
   369         //load appropriate icon from svg file
   236         HbLabel* label1 = qobject_cast<HbLabel*> (loader.findWidget("icon"));
   370         HbLabel* label1 = qobject_cast<HbLabel*> (loader.findWidget("icon"));
   237         HbIcon* icon1 = new HbIcon(":/devman_icon/resources/iconnotifier.svg");
   371         HbIcon* icon1 = new HbIcon(":/devman_icon/resources/iconnotifier.svg");
   238         label1->setIcon(*icon1);
   372         label1->setIcon(*icon1);
   239         //label1->setMode(QIcon::Normal);
   373         //label1->setMode(QIcon::Normal);
   240         //label1->setState(QIcon::Off);
   374         //label1->setState(QIcon::Off);
   241         label1->setToolTip("Mode=Normal, State=Off");
   375         label1->setToolTip("Mode=Normal, State=Off");
   242 
   376 
       
   377         QObject::connect(dialog, SIGNAL(finished(HbAction*)), 
       
   378                 this, SLOT(noteTimedOut(HbAction*)));
   243         QObject::connect(primaryAction, SIGNAL(triggered()), this,
   379         QObject::connect(primaryAction, SIGNAL(triggered()), this,
   244                 SLOT(okSelected()));
   380                 SLOT(okSelected()));
   245 
   381 
   246         QObject::connect(secondaryAction, SIGNAL(triggered()), this,
   382         QObject::connect(secondaryAction, SIGNAL(triggered()), this,
   247                 SLOT(cancelSelected()));
   383                 SLOT(cancelSelected()));
   266 
   402 
   267         HbLabel *content = qobject_cast<HbLabel *> (loader.findWidget(
   403         HbLabel *content = qobject_cast<HbLabel *> (loader.findWidget(
   268                 "qtl_dialog_pri5"));
   404                 "qtl_dialog_pri5"));
   269 
   405 
   270         QString serverinitmessage = hbTrId(
   406         QString serverinitmessage = hbTrId(
   271                 "txt_device_update_info_update_serverpush_informative").arg(
   407                 "txt_deviceupdate_info_updating_device_from_server").arg(
   272                 servername);
   408                 servername);
   273 
   409 
   274         //getserverspecifictexttodisplay(profileid, uimode, serverinitmessage);
   410         //getserverspecifictexttodisplay(profileid, uimode, serverinitmessage);
   275         content->setPlainText(serverinitmessage);
   411         content->setPlainText(serverinitmessage);
   276 
   412 
   395     //msymnotifier->setstatus(-3);
   531     //msymnotifier->setstatus(-3);
   396     iPtr->dmDevdialogDismissed(devicemanagementnotifierwidget::EServerAlertNote,-3);
   532     iPtr->dmDevdialogDismissed(devicemanagementnotifierwidget::EServerAlertNote,-3);
   397     
   533     
   398     }
   534     }
   399 
   535 
       
   536 void syncmlnotifier::noteTimedOut(HbAction* action)
       
   537     {
       
   538     qDebug("Pkg zero note timed out");
       
   539     if (action == NULL)
       
   540         {
       
   541         int timeout = -33; //KErrTimedOut
       
   542         msymnotifier->setstatus(timeout);
       
   543         if(mDefaultServerPkgZero) //For default server action is RSK
       
   544         iPtr->dmDevdialogDismissed(
       
   545                 devicemanagementnotifierwidget::EServerAlertNote, -3);
       
   546         else //For Non default server action is LSK
       
   547         iPtr->dmDevdialogDismissed(
       
   548                 devicemanagementnotifierwidget::EServerAlertNote, 0);	        	
       
   549         }
       
   550     }
       
   551 
   400 syncmlnotifier::~syncmlnotifier()
   552 syncmlnotifier::~syncmlnotifier()
   401     {
   553     {
   402     qDebug("syncmlnotifier::~syncmlnotifier");
   554     qDebug("syncmlnotifier::~syncmlnotifier");
   403         qDebug("syncmlnotifier::~syncmlnotifier end");
   555         qDebug("syncmlnotifier::~syncmlnotifier end");
   404     }
   556     }