messagingapp/msgsettings/settingsview/src/msgsettingengine.cpp
branchRCL_3
changeset 57 ebe688cedc25
equal deleted inserted replaced
54:fa1df4b99609 57:ebe688cedc25
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:This class provides API m/w for msg settings plugin
       
    15  *
       
    16  */
       
    17 
       
    18 #include "qstringlist.h"
       
    19 #include "debugtraces.h"
       
    20 
       
    21 
       
    22 #include "msgsettingengine.h"
       
    23 #include "smssettingsprivate.h"
       
    24 #include "mmssettingprivate.h"
       
    25 #include <xqconversions.h>
       
    26 
       
    27 //Constructor
       
    28 MsgSettingEngine::MsgSettingEngine()
       
    29 {
       
    30 #ifdef _DEBUG_TRACES_
       
    31     qDebug() << "Enter MsgSettingEngine::MsgSettingEngine";
       
    32 #endif
       
    33 
       
    34 
       
    35     QT_TRAP_THROWING(dptr_smsSettings = SmsSettingsPrivate::NewL());
       
    36     QT_TRAP_THROWING(dptr_mmsSettings = MmsSettingsPrivate::NewL());
       
    37 
       
    38 #ifdef _DEBUG_TRACES_
       
    39     qDebug() << "Exit MsgSettingEngine::MsgSettingEngine";
       
    40 #endif
       
    41 
       
    42 }
       
    43 
       
    44 //Destructor
       
    45 MsgSettingEngine::~MsgSettingEngine()
       
    46 {
       
    47 #ifdef _DEBUG_TRACES_
       
    48     qDebug() << "Enter MsgSettingEngine::~MsgSettingEngine";
       
    49 #endif
       
    50 
       
    51 
       
    52     delete dptr_smsSettings;
       
    53     delete dptr_mmsSettings;
       
    54 
       
    55 #ifdef _DEBUG_TRACES_
       
    56     qDebug() << "Exit MsgSettingEngine::~MsgSettingEngine";
       
    57 #endif
       
    58 
       
    59 }
       
    60 
       
    61 /**
       
    62  * set the character encoding
       
    63  * @param encoding specifying encoding type
       
    64  */
       
    65 void MsgSettingEngine::setCharacterEncoding(MsgSettingEngine::CharacterEncoding encoding)
       
    66 {
       
    67 #ifdef _DEBUG_TRACES_
       
    68     qDebug() << "MsgSettingEngine::setCharacterEncoding: " << encoding;
       
    69 #endif
       
    70 
       
    71 
       
    72     TBool flag = EFalse;
       
    73 
       
    74     if (encoding == MsgSettingEngine::FullSupport)
       
    75     {
       
    76         flag = ETrue;
       
    77     }
       
    78     QT_TRAP_THROWING(dptr_smsSettings->setCharacterEncodingL(flag));
       
    79     
       
    80 #ifdef _DEBUG_TRACES_
       
    81     qDebug() << "MsgSettingEngine::setCharacterEncoding";
       
    82 #endif
       
    83 
       
    84 }
       
    85 
       
    86 /**
       
    87  * returns settings delivery report status
       
    88  * and character encoding
       
    89  * @param encoding for char encoding
       
    90  */
       
    91 void MsgSettingEngine::settingsCharEncoding( 
       
    92         MsgSettingEngine::CharacterEncoding& encoding )
       
    93 {
       
    94     QDEBUG_WRITE("settingsServiceMessagesAndCharEncoding");
       
    95     
       
    96     TBool encoding1;
       
    97         
       
    98     QT_TRAP_THROWING(dptr_smsSettings->settingsCharEncodingL(encoding1));
       
    99     
       
   100     if (encoding1)
       
   101     {
       
   102         encoding = MsgSettingEngine::FullSupport;
       
   103     }
       
   104     else
       
   105         encoding = MsgSettingEngine::ReducedSupport;
       
   106     
       
   107     return;
       
   108 }
       
   109 
       
   110 /**
       
   111  * set the mms retrieval mode
       
   112  * @param retrieval specifying mode
       
   113  */
       
   114 void MsgSettingEngine::setMMSRetrieval(MsgSettingEngine::MmsRetrieval retrieval)
       
   115 {
       
   116 #ifdef _DEBUG_TRACES_
       
   117     qDebug() << "MsgSettingEngine::setMMSRetrieval " << retrieval;
       
   118 #endif
       
   119 
       
   120 
       
   121     QT_TRAP_THROWING(dptr_mmsSettings->setMMSRetrievalL(retrieval));
       
   122 
       
   123 #ifdef _DEBUG_TRACES_
       
   124     qDebug() << "Exit setMMSRetrieval";
       
   125 #endif
       
   126 
       
   127 }
       
   128 
       
   129 /**
       
   130  * set the anonymous message
       
   131  * @param status true or false
       
   132  */
       
   133 void MsgSettingEngine::setAnonymousMessages(bool status)
       
   134 {
       
   135 #ifdef _DEBUG_TRACES_
       
   136     qDebug() << "MsgSettingEngine::setAnonymousMessages " << status;
       
   137 #endif
       
   138 
       
   139 
       
   140     QT_TRAP_THROWING (dptr_mmsSettings->setAnonymousMessagesL(status));
       
   141 
       
   142 #ifdef _DEBUG_TRACES_
       
   143     qDebug() << "Exit setAnonymousMessages";
       
   144 #endif
       
   145 
       
   146 }
       
   147 
       
   148 /**
       
   149  * set for receiving MMS Adverts
       
   150  * @param status for true or false
       
   151  */
       
   152 void MsgSettingEngine::setReceiveMMSAdverts(bool status)
       
   153 {
       
   154 #ifdef _DEBUG_TRACES_
       
   155     qDebug() << "MsgSettingEngine::setReceiveMMSAdverts " << status;
       
   156 #endif
       
   157 
       
   158 
       
   159     QT_TRAP_THROWING(dptr_mmsSettings->setReceiveMMSAdvertsL(status));
       
   160 
       
   161 #ifdef _DEBUG_TRACES_
       
   162     qDebug() << "Exit setReceiveMMSAdverts";
       
   163 #endif
       
   164 
       
   165 }
       
   166 
       
   167 /**
       
   168  * for view 2 mms advance settings\
       
   169 * get all the fields of mms advance setting
       
   170  * @param retrieval return for mms retrieval
       
   171  * @param anonymous return status true or false
       
   172  * @param mmsadverts return status true or false
       
   173  */
       
   174 void MsgSettingEngine::advanceMmsSettings(MsgSettingEngine::MmsRetrieval& retrieval,
       
   175                                           bool& anonymousStatus,
       
   176                                           bool& mmsAdvertsStatus)
       
   177 {
       
   178 #ifdef _DEBUG_TRACES_
       
   179     qDebug() << "MsgSettingEngine::setReceiveMMSAdverts";
       
   180 #endif
       
   181 
       
   182 
       
   183     TBool anonymous_Status;
       
   184     TBool mmsAdverts_Status;
       
   185     QT_TRAP_THROWING(dptr_mmsSettings->advanceMmsSettingsL(retrieval,
       
   186                                          anonymous_Status,
       
   187                                          mmsAdverts_Status));
       
   188 
       
   189     anonymousStatus = (bool) anonymous_Status;
       
   190     mmsAdvertsStatus = (bool) mmsAdverts_Status;
       
   191 
       
   192 #ifdef _DEBUG_TRACES_
       
   193     qDebug() << "Exit setReceiveMMSAdverts " << retrieval << " "
       
   194             << anonymousStatus << " " << mmsAdvertsStatus;
       
   195 #endif
       
   196 
       
   197 }
       
   198 
       
   199 /**
       
   200  * get all the MMs access points
       
   201  * @param returns all the access point names
       
   202  * @attention to be displayed as per the index o to total count
       
   203  */
       
   204 void MsgSettingEngine::allMMsAcessPoints(QStringList& nameList,
       
   205                                          int& defaultIndex)
       
   206 {
       
   207 #ifdef _DEBUG_TRACES_
       
   208     qDebug() << "MsgSettingEngine::allMMsAcessPoints";
       
   209 #endif
       
   210 
       
   211 
       
   212     RPointerArray<HBufC> accessPoints;
       
   213     //= new(ELeave)RPointerArray<HBufC>();
       
   214 
       
   215     QT_TRAP_THROWING( dptr_mmsSettings->getAllAccessPointsL(accessPoints, defaultIndex));
       
   216 
       
   217     for (int i = 0; i < accessPoints.Count(); i++)
       
   218         {
       
   219         HBufC* name = static_cast<HBufC *> (accessPoints[i]);
       
   220         QString qName = XQConversions::s60DescToQString(name->Des());
       
   221         nameList.append(qName);
       
   222 #ifdef _DEBUG_TRACES_
       
   223         qDebug() << "\n " << qName;
       
   224 #endif
       
   225 
       
   226         }
       
   227     accessPoints.ResetAndDestroy();
       
   228 
       
   229 #ifdef _DEBUG_TRACES_
       
   230     qDebug() << "Exit allMMsAcessPoints count = " << nameList.count()
       
   231             << " Default:" << defaultIndex;
       
   232 #endif
       
   233 
       
   234 }
       
   235 
       
   236 /**
       
   237  * set the default access point
       
   238  * @param index specifying the index
       
   239  */
       
   240 void MsgSettingEngine::setMMSAccesspoint(int index)
       
   241 {
       
   242 #ifdef _DEBUG_TRACES_
       
   243     qDebug() << "MsgSettingEngine::setMMSAccesspoint " << index;
       
   244 #endif
       
   245 
       
   246 
       
   247     QT_TRAP_THROWING(dptr_mmsSettings->setMMSAccesspointL(index));
       
   248 
       
   249 #ifdef _DEBUG_TRACES_
       
   250     qDebug() << "Exit setMMSAccesspoint ";
       
   251 #endif
       
   252 
       
   253 }
       
   254 
       
   255 /**
       
   256  * get the list of all SMS Message Centres
       
   257  * @param list of all names QString
       
   258  */
       
   259 void MsgSettingEngine::allSMSMessageCenter(QStringList& nameList,
       
   260                                            int& defaultIndex)
       
   261 {
       
   262 
       
   263 #ifdef _DEBUG_TRACES_
       
   264     qDebug() << "MsgSettingEngine::allSMSMessageCenter";
       
   265 #endif
       
   266 
       
   267 
       
   268     RPointerArray<HBufC> accessPoints;
       
   269 
       
   270     QT_TRAP_THROWING(dptr_smsSettings->getAllSMSMessageCenterL(accessPoints, defaultIndex));
       
   271 
       
   272     for (int i = 0; i < accessPoints.Count(); i++)
       
   273         {
       
   274         HBufC* name = accessPoints[i];
       
   275         QString qName = XQConversions::s60DescToQString(name->Des());
       
   276         nameList.append(qName);
       
   277 #ifdef _DEBUG_TRACES_
       
   278         qDebug() << "\n qName";
       
   279 #endif
       
   280 
       
   281         }
       
   282     accessPoints.ResetAndDestroy();
       
   283 
       
   284 #ifdef _DEBUG_TRACES_
       
   285     qDebug() << "Exit allSMSMessageCenter count = " << nameList.count()
       
   286             << " Default:" << defaultIndex;
       
   287 #endif
       
   288 
       
   289 }
       
   290 
       
   291 /**
       
   292  * set the default SMS message centre
       
   293  * @param index specifying default index
       
   294  */
       
   295 void MsgSettingEngine::setSMSMessageCenter(int index)
       
   296 {
       
   297 #ifdef _DEBUG_TRACES_
       
   298     qDebug() << "MsgSettingEngine::setSMSMessageCenter " << index;
       
   299 #endif
       
   300 
       
   301 
       
   302     QT_TRAP_THROWING(dptr_smsSettings->setSMSMessageCenterL(index));
       
   303 
       
   304 #ifdef _DEBUG_TRACES_
       
   305     qDebug() << "Exit setSMSMessageCenter ";
       
   306 #endif
       
   307 
       
   308 }
       
   309 
       
   310 /**
       
   311  * for editing the SMS messafe Centre
       
   312  * @param name specifying center name
       
   313  * @param number specifying center number
       
   314  * @param index specying index of message list
       
   315  */
       
   316 void MsgSettingEngine::editSmsMessageCenter(QString& centreName,
       
   317                                             QString& centreNumber, int index)
       
   318 {
       
   319 #ifdef _DEBUG_TRACES_
       
   320     qDebug() << "MsgSettingEngine::editSmsMessageCenter " << index << " "
       
   321             << centreName << " " << centreNumber;
       
   322 #endif
       
   323 
       
   324     HBufC* d_addr = XQConversions::qStringToS60Desc(centreNumber);
       
   325     HBufC* d_name = XQConversions::qStringToS60Desc(centreName);
       
   326 
       
   327     QT_TRAP_THROWING(dptr_smsSettings->editSMSServiceCentreL(d_addr, d_name, index));
       
   328     delete d_addr;
       
   329     delete d_name;
       
   330 
       
   331 #ifdef _DEBUG_TRACES_
       
   332     qDebug() << "Exit editSmsMessageCenter ";
       
   333 #endif
       
   334 
       
   335 }
       
   336 
       
   337 /**
       
   338  * for add new sms message centre
       
   339  * @param name specifying center name
       
   340  * @param number specifying center number
       
   341  */
       
   342 void MsgSettingEngine::addSmsMessageCenter(QString& centreName,
       
   343                                            QString& centreNumber)
       
   344 {
       
   345 #ifdef _DEBUG_TRACES_
       
   346     qDebug() << "MsgSettingEngine::addSmsMessageCenter " << centreName << " "
       
   347             << centreNumber;
       
   348 #endif
       
   349 
       
   350 
       
   351     HBufC* d_addr = XQConversions::qStringToS60Desc(centreNumber);
       
   352     HBufC* d_name = XQConversions::qStringToS60Desc(centreName);
       
   353 
       
   354     QT_TRAP_THROWING(dptr_smsSettings->addSmsMessageCenterL(d_addr, d_name));
       
   355     delete d_addr;
       
   356     delete d_name;
       
   357 
       
   358 #ifdef _DEBUG_TRACES_
       
   359     qDebug() << "Exit addSmsMessageCenter ";
       
   360 #endif
       
   361 
       
   362 }
       
   363 
       
   364 /**
       
   365  * for delete sms message centre
       
   366  * @refer to header file
       
   367  */
       
   368 void MsgSettingEngine::deleteSmsMessageCenter(int deleteIndex)
       
   369 {
       
   370     QT_TRAP_THROWING( dptr_smsSettings->deleteSmsMessageCenterL(deleteIndex));
       
   371 }
       
   372 
       
   373 /**
       
   374  * get the sms message centre namd and number
       
   375  * @index for which center needs
       
   376  * @param return name specifying center name
       
   377  * @param return number specifying center number
       
   378  */
       
   379 void MsgSettingEngine::smsCenterNameAndNumber(int index, QString& centreName,
       
   380                                               QString& centreNumber)
       
   381 {
       
   382 #ifdef _DEBUG_TRACES_
       
   383     qDebug() << "MsgSettingEngine::smsCenterNameAndNumber " << index;
       
   384 #endif
       
   385 
       
   386 
       
   387     HBufC* d_addr;
       
   388     HBufC* d_name;
       
   389 
       
   390     QT_TRAP_THROWING(  dptr_smsSettings->smsCenterNameAndNumberL(index, &d_addr, &d_name));
       
   391 
       
   392     centreNumber = XQConversions::s60DescToQString(d_addr->Des());
       
   393     centreName = XQConversions::s60DescToQString(d_name->Des());
       
   394 
       
   395 #ifdef _DEBUG_TRACES_
       
   396     qDebug() << "Exit smsCenterNameAndNumber " << centreNumber << " "
       
   397             << centreName;
       
   398 #endif
       
   399 
       
   400 }
       
   401 
       
   402 //eof
       
   403