deviceupdatesui/cpqtsp/src/CpQtSpView.cpp
author hgs
Sun, 21 Mar 2010 15:34:22 +0530
changeset 36 9eefb50e711a
parent 33 7464c1e21dae
permissions -rw-r--r--
201011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     1
/*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     3
* All rights reserved.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     8
*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     9
* Initial Contributors:
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    11
*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    12
* Contributors:
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    13
*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    14
* Description: 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    15
*     Bio control for Provisioning documents.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    16
*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    17
*/
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    18
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    19
#include <hbapplication.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    20
#include <hbtoolbar.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    21
#include <hbaction.h>
36
hgs
parents: 33
diff changeset
    22
#include <hbmenu.h>
33
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    23
#include <HbTextItem>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    24
#include <HbFontSpec>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    25
#include <HbMessageBox>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    26
#include <QGraphicsLinearLayout>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    27
#include <xqserviceprovider.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    28
#include <xqservicerequest.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    29
#include <xqserviceutil.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    30
#include <e32base.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    31
#include <flogger.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    32
#include <CWPNameValue.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    33
#include <CWPEngine.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    34
#include <CpQtSpView.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    35
#include <CpQtSpMainWindow.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    36
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    37
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    38
CpQtSpView::CpQtSpView(CpQtSp* service,QGraphicsItem *parent)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    39
    : HbView(parent), iServiceProvider(service)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    40
{ 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    41
    setTitle(tr("Messaging"));
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    42
    HbToolBar* toolBar = this->toolBar(); 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    43
    HbMenu* menu = this->menu();       
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    44
    HbAction* saveAction = new HbAction("Save");     
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    45
    connect(saveAction, SIGNAL(triggered()), this, SLOT(saveProvisoningMessage()));        
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    46
    HbAction* DeleteAction = new HbAction("Delete");
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    47
    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    48
    toolBar->addAction(saveAction);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    49
    toolBar->addAction(DeleteAction);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    50
    toolBar->setOrientation(Qt::Horizontal);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    51
    iPrimaryFont = new HbFontSpec(HbFontSpec::Primary);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    52
    iSecondaryFont = new HbFontSpec(HbFontSpec::Secondary);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    53
    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    54
    layout = new QGraphicsLinearLayout(Qt::Vertical, this);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    55
    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    56
    QString str = hbTrId("txt_device_update_dblist_configuration_message");
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    57
    QString str1 = hbTrId("txt_device_update_dblist_product_code_val_save_to");
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    58
    HbTextItem* mPrimaryItem = new HbTextItem(str, this);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    59
    HbTextItem* mSecondaryItem = new HbTextItem(str1, this);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    60
       
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    61
    QFont font = iPrimaryFont->font();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    62
    mPrimaryItem->setFont(font);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    63
        
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    64
    font = iSecondaryFont->font();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    65
    mSecondaryItem->setFont(font);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    66
    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    67
    layout->addItem(mPrimaryItem);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    68
    layout->addItem(mSecondaryItem);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    69
   
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    70
    setLayout(layout);     
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    71
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    72
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    73
void CpQtSpView::constructView()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    74
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    75
    iBio = CWPBioControl::NewL(iServiceProvider->returnSession(),iServiceProvider->returnId());
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    76
    RPointerArray<CWPNameValue>* iArray = iBio->CollectItemsLC();    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    77
    TBufC<200> Name;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    78
    TBufC<200> Value;    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    79
    HbTextItem* mPrimaryItem[100];
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    80
    HbTextItem* mSecondaryItem[100];
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    81
    HbTextItem* mSecondaryItemBlank = new HbTextItem("", this);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    82
    QFont pfont = iPrimaryFont->font();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    83
    QFont sfont = iSecondaryFont->font();      
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    84
   
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    85
	TBuf<200> currentTitle(KNullDesC);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    86
	
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    87
    for( TInt item = 0; item < iArray->Count(); item++ )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    88
    {  	
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    89
    	CWPNameValue* pair = ((*iArray)[item]);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    90
    	Name = pair->Name();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    91
    	if(Name.Compare(currentTitle) !=0 )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    92
    	{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    93
    	QString qname((QChar*)Name.Ptr(),Name.Length());
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    94
    	mPrimaryItem[item] = new HbTextItem(qname);    	
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    95
    	mPrimaryItem[item]->setFont(pfont);    	
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    96
    	layout->addItem(mSecondaryItemBlank);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    97
    	layout->addItem(mPrimaryItem[item]);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    98
    	currentTitle.Copy(Name);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    99
    	}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   100
    	    	
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   101
    	Value = pair->Value();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   102
    	QString qvalue((QChar*)Value.Ptr(),Value.Length());   
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   103
    	mSecondaryItem[item] = new HbTextItem(qvalue);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   104
    	mSecondaryItem[item]->setFont(sfont);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   105
    	layout->addItem(mSecondaryItem[item]);  
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   106
   }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   107
    CleanupStack::PopAndDestroy();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   108
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   109
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   110
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   111
void CpQtSpView::saveProvisoningMessage()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   112
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   113
  CWPEngine* engine = iBio->returnEngine();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   114
  int errSave = KErrNone;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   115
  
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   116
  for(TInt i=0; i < engine->ItemCount(); i++)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   117
  {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   118
   TRAP( errSave, engine->SaveL(i) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   119
  } 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   120
  
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   121
  if( errSave == KErrNone )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   122
  {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   123
  	//For testing purpose. Will be removed in future.
36
hgs
parents: 33
diff changeset
   124
    //HbMessageBox::launchInformationMessageBox("Message Saved");
33
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   125
  }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   126
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   127
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   128
CpQtSpView::~CpQtSpView()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   129
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   130
    delete iBio;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   131
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   132
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   133
void CpQtSpView::requestCompleted(const QVariant& value)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   134
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   135
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   136
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   137
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   138
CpQtSp::CpQtSp(QObject* parent)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   139
: XQServiceProvider("com.nokia.services.MDM.Provisioning",parent)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   140
{  
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   141
    publishAll();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   142
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   143
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   144
CpQtSp::~CpQtSp()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   145
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   146
	delete iObserver;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   147
	delete iSession;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   148
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   149
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   150
void CpQtSp::complete()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   151
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   152
   QString retvalue ="";
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   153
   completeRequest(1,retvalue);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   154
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   155
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   156
QString CpQtSp::ProcessMessage(const QString& tmsvid)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   157
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   158
    iId = tmsvid.toInt();	
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   159
    TMsvSelectionOrdering sort;    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   160
    sort.SetShowInvisibleEntries(ETrue); 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   161
    iObserver = new(ELeave) CObserver;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   162
    iSession = CMsvSession::OpenSyncL(*iObserver);    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   163
    emit showView();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   164
    setCurrentRequestAsync();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   165
    return "";    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   166
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   167
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   168
TMsvId CpQtSp::returnId()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   169
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   170
	return iId;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   171
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   172
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   173
CMsvSession* CpQtSp::returnSession()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   174
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   175
  return iSession;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   176
}