phoneengine/networkhandlingstarter/src/networkhandlingstarter_p.cpp
changeset 56 5bcb308bd24d
parent 45 6b911d05207e
equal deleted inserted replaced
46:bc5a64e5bc3c 56:5bcb308bd24d
     1 /*
     1 /*
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 #include <hbdevicemessagebox.h>
    18 #include <hbdevicemessagebox.h>
    19 #include <hbaction.h>
    19 #include <hbaction.h>
    20 #include <cppluginlauncher.h>
       
    21 #include <hbinstance.h>
       
    22 #include <hbview.h>
       
    23 #include <xqserviceutil.h>
    20 #include <xqserviceutil.h>
    24 #include <cpbasesettingview.h>
    21 #include <xqaiwrequest.h>
       
    22 #include <xqappmgr.h>
       
    23 #include <hbtranslator.h>
    25 
    24 
    26 #include "networkhandlingstarter_p.h"
    25 #include "networkhandlingstarter_p.h"
    27 #include "networkhandlingstarterlogging.h"
    26 #include "networkhandlingstarterlogging.h"
    28 #include "cnetworklistener.h"
    27 #include "cnetworklistener.h"
    29 
    28 
    30 /*!
    29 /*!
    31     Constructor of NetworkHandlingStarterPrivate.
    30     Constructor of NetworkHandlingStarterPrivate.
    32  */
    31  */
    33 NetworkHandlingStarterPrivate::NetworkHandlingStarterPrivate(QObject *parent) : 
    32 NetworkHandlingStarterPrivate::NetworkHandlingStarterPrivate(QObject *parent) 
    34     QObject(parent), m_note(NULL)
    33     : 
       
    34     QObject(parent), 
       
    35     m_networkListener(NULL), 
       
    36     m_note(NULL)
    35 {
    37 {
    36     DPRINT << ": IN";
    38     DPRINT << ": IN";
    37     
    39     
    38     QT_TRAP_THROWING(m_networkListener = CNetworkListener::NewL(*this));
    40     QT_TRAP_THROWING(m_networkListener = CNetworkListener::NewL(*this))
    39     
    41     
    40     DPRINT << ": OUT";
    42     DPRINT << ": OUT";
    41 }
    43 }
    42 
    44 
    43 /*!
    45 /*!
    65     if (m_note) {
    67     if (m_note) {
    66         m_note->close();
    68         m_note->close();
    67         delete m_note;
    69         delete m_note;
    68         m_note = NULL;
    70         m_note = NULL;
    69     }
    71     }
       
    72     HbTranslator commonTranslator("common");
       
    73     HbTranslator telephone_cpTranslator("telephone_cp");
    70     m_note = new HbDeviceMessageBox(
    74     m_note = new HbDeviceMessageBox(
    71         hbTrId("txt_phone_info_network_lost_select_network"), 
    75         hbTrId("txt_phone_info_network_lost_select_network"), 
    72         HbMessageBox::MessageTypeQuestion);
    76         HbMessageBox::MessageTypeQuestion);
    73     HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_yes"), m_note);
    77     HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_yes"), m_note);
    74     m_note->setAction(primaryAction, HbDeviceMessageBox::AcceptButtonRole); 
    78     m_note->setAction(primaryAction, HbDeviceMessageBox::AcceptButtonRole); 
    84 }
    88 }
    85 
    89 
    86 /*!
    90 /*!
    87     NetworkHandlingStarterPrivate::RemoveNote()
    91     NetworkHandlingStarterPrivate::RemoveNote()
    88  */
    92  */
       
    93 
    89 void NetworkHandlingStarterPrivate::RemoveNote()
    94 void NetworkHandlingStarterPrivate::RemoveNote()
    90 {
    95 {
    91     DPRINT << ": IN";
    96     DPRINT << ": IN";
    92     
    97     
    93     if (m_note) {
    98     if (m_note) {
    98     
   103     
    99     DPRINT << ": OUT";
   104     DPRINT << ": OUT";
   100 }
   105 }
   101 
   106 
   102 /*!
   107 /*!
   103     NetworkHandlingStarterPrivate::InitaliseCpNetworkPluginView()
       
   104  */
       
   105 bool NetworkHandlingStarterPrivate::InitaliseCpNetworkPluginView()
       
   106 {
       
   107     DPRINT << ": IN";
       
   108     
       
   109     bool ok(false);
       
   110     CpBaseSettingView* view = CpPluginLauncher::launchSettingView("cpnetworkplugin");
       
   111     if (view) {
       
   112         if (QString(view->metaObject()->className()) == 
       
   113             QString("CpNetworkPluginView")) {
       
   114             QObject::connect(
       
   115                 view, SIGNAL(aboutToClose()), 
       
   116                 this, SLOT(ViewDone()));
       
   117             QObject::connect(
       
   118                 this, SIGNAL(SearchAvailableNetworks()), 
       
   119                 view, SLOT(SearchAvailableNetworks()));
       
   120             ok = true;
       
   121         }
       
   122     }
       
   123     
       
   124     DPRINT << ": OUT";
       
   125     return ok;
       
   126 }
       
   127 
       
   128 /*!
       
   129     NetworkHandlingStarterPrivate::LaunchCpNetworkPluginView()
   108     NetworkHandlingStarterPrivate::LaunchCpNetworkPluginView()
   130  */
   109  */
   131 void NetworkHandlingStarterPrivate::LaunchCpNetworkPluginView()
   110 void NetworkHandlingStarterPrivate::LaunchCpNetworkPluginView()
   132 {
   111 {
   133     DPRINT << ": IN";
   112     DPRINT << ": IN";
   134     
   113     
   135     if (InitaliseCpNetworkPluginView()) {
   114     XQApplicationManager appManager;
   136         DPRINT << ": Show network settings view";
   115     QList<QVariant> args;
   137         HbMainWindow *mainWnd = MainWindow();
   116     QString service;
   138         if (mainWnd) {
   117     QString interface;
   139             mainWnd->show();
   118     QString operation;
   140             XQServiceUtil::toBackground(false);
   119     QVariantHash hash;
   141         }
   120     QVariantMap map;
   142         emit SearchAvailableNetworks();
   121     
   143     }
   122     interface = "com.nokia.symbian.ICpPluginLauncher";
       
   123     operation = "launchSettingView(QString,QVariant)";
       
   124     args << QVariant("cpnetworkplugin.dll");            
       
   125     hash["command"] = "searchAvailableNetworks";
       
   126     args << hash;
       
   127 
       
   128     QScopedPointer<XQAiwRequest> request( service.isEmpty() ? 
       
   129         appManager.create(interface, operation, false):
       
   130         appManager.create(service, interface, operation, false));
       
   131     if (request){
       
   132         request->setArguments(args);
       
   133         request->send();
       
   134     } 
   144     
   135     
   145     DPRINT << ": OUT";
   136     DPRINT << ": OUT";
   146 }
   137 }
   147 
   138 
   148 /*!
       
   149     NetworkHandlingStarterPrivate::ViewDone()
       
   150  */
       
   151 void NetworkHandlingStarterPrivate::ViewDone()
       
   152 {
       
   153     HbMainWindow *mainWnd = MainWindow();
       
   154     if (mainWnd) {
       
   155         mainWnd->hide();
       
   156     }
       
   157     XQServiceUtil::toBackground(true);
       
   158 }
       
   159 
       
   160 /*!
       
   161     NetworkHandlingStarterPrivate::MainWindow()
       
   162  */
       
   163 
       
   164 HbMainWindow * NetworkHandlingStarterPrivate::MainWindow() 
       
   165 {
       
   166     HbMainWindow *window(NULL);
       
   167     QList<HbMainWindow*> mainWindows = hbInstance->allMainWindows();
       
   168     if (!mainWindows.isEmpty()) {
       
   169         window = mainWindows.front();
       
   170     }
       
   171     return window;
       
   172 }
       
   173 
       
   174 // End of File.
   139 // End of File.