phoneapp/phoneuiutils/src/tphonecmdparamquery.cpp
changeset 37 ba76fc04e6c2
child 51 f39ed5e045e0
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2005 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: Implementation of TPhoneCmdParamQuery class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "tphonecmdparamquery.h"
       
    21 #include "phoneui.pan"
       
    22 
       
    23 const TInt KUninitializedTimeOutCmd = -1;
       
    24 
       
    25 // ================= MEMBER FUNCTIONS =======================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // TPhoneCmdParamQuery::TPhoneCmdParamQuery
       
    29 // C++ default constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 EXPORT_C TPhoneCmdParamQuery::TPhoneCmdParamQuery():
       
    34     TPhoneCommandParam(),
       
    35     iDialogResourceId( 0 ),
       
    36     iDialogPrompt( KNullDesC ),
       
    37     iDefaultCbaResourceId( 0 ), 
       
    38     iContentCbaResourceId( 0 ), 
       
    39     iDataText( NULL ),
       
    40     iQueryType( EPhoneQueryDialog ),
       
    41     iSendKeyEnabled( EFalse ),
       
    42     iTimeOut( 0 ),
       
    43     iTone( 0 ),
       
    44     iCustomCmdForTimeOut( KUninitializedTimeOutCmd ),
       
    45     iCommandObserver( NULL ),
       
    46     iItemTextArray( NULL )
       
    47     {
       
    48     iParamId = EPhoneParamIdQuery;
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // TPhoneCmdParamQuery::TPhoneCmdParamQuery
       
    53 // C++ copy constructor can NOT contain any code, that might leave.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C TPhoneCmdParamQuery::TPhoneCmdParamQuery( 
       
    57         const TPhoneCmdParamQuery& aParam )
       
    58     {
       
    59     iParamId = aParam.iParamId;
       
    60     iDialogResourceId = aParam.iDialogResourceId;
       
    61     iDialogPrompt.Set( aParam.iDialogPrompt );
       
    62     iDefaultCbaResourceId = aParam.iDefaultCbaResourceId;
       
    63     iContentCbaResourceId = aParam.iContentCbaResourceId;
       
    64     iDataText = aParam.iDataText;
       
    65     iQueryType= aParam.iQueryType;
       
    66     iSendKeyEnabled = aParam.iSendKeyEnabled;
       
    67     iTimeOut = aParam.iTimeOut;
       
    68     iTone = aParam.iTone;
       
    69     iCustomCmdForTimeOut = aParam.iCustomCmdForTimeOut;
       
    70     iCommandObserver = aParam.iCommandObserver;
       
    71     iItemTextArray = aParam.iItemTextArray;
       
    72     for ( TInt i = aParam.iCbaCommandMappings.Count() - 1; 0 <= i; i-- )
       
    73         {
       
    74         iCbaCommandMappings[i] = aParam.iCbaCommandMappings[i];
       
    75         }
       
    76     }
       
    77 
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // TPhoneCmdParamQuery::operator=
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 EXPORT_C TPhoneCmdParamQuery& TPhoneCmdParamQuery::operator=( 
       
    84         const TPhoneCmdParamQuery& aParam )
       
    85     {
       
    86     if ( this != &aParam )
       
    87         {
       
    88         iParamId = aParam.iParamId;
       
    89         iDialogResourceId = aParam.iDialogResourceId;
       
    90         iDialogPrompt.Set( aParam.iDialogPrompt );
       
    91         iDefaultCbaResourceId = aParam.iDefaultCbaResourceId;
       
    92         iContentCbaResourceId = aParam.iContentCbaResourceId;
       
    93         iDataText = aParam.iDataText;
       
    94         iQueryType= aParam.iQueryType;
       
    95         iSendKeyEnabled = aParam.iSendKeyEnabled;
       
    96         iTimeOut = aParam.iTimeOut;
       
    97         iTone = aParam.iTone;
       
    98         iCustomCmdForTimeOut = aParam.iCustomCmdForTimeOut;
       
    99         iCommandObserver = aParam.iCommandObserver;
       
   100         iItemTextArray = aParam.iItemTextArray;
       
   101         for ( TInt i = aParam.iCbaCommandMappings.Count() - 1; 0 <= i; i-- )
       
   102             {
       
   103             iCbaCommandMappings[i] = aParam.iCbaCommandMappings[i];
       
   104             }
       
   105         }
       
   106     
       
   107     return *this;
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------
       
   111 // TPhoneCmdParamQuery::SetQueryResourceId
       
   112 // Sets the query dialog resource id
       
   113 // (other items were commented in a header).
       
   114 // ---------------------------------------------------------
       
   115 //
       
   116 EXPORT_C void TPhoneCmdParamQuery::SetQueryResourceId( TInt aDialogResourceId )
       
   117     {
       
   118     __ASSERT_DEBUG( aDialogResourceId, 
       
   119         Panic( EPhoneUtilsParameterNotInitialized ) );
       
   120     iDialogResourceId = aDialogResourceId;   
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------
       
   124 // TPhoneCmdParamQuery::QueryResourceId
       
   125 // Returns the query dialog's resource id
       
   126 // (other items were commented in a header).
       
   127 // ---------------------------------------------------------
       
   128 //
       
   129 EXPORT_C TInt TPhoneCmdParamQuery::QueryResourceId() const
       
   130     {   
       
   131     return iDialogResourceId;
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------
       
   135 // TPhoneCmdParamQuery::SetQueryPrompt
       
   136 // Sets the query dialog's prompt text
       
   137 // (other items were commented in a header).
       
   138 // ---------------------------------------------------------
       
   139 //
       
   140 EXPORT_C void TPhoneCmdParamQuery::SetQueryPrompt( const TDesC& aDialogPrompt )
       
   141    {
       
   142    iDialogPrompt.Set( aDialogPrompt );
       
   143    }
       
   144 
       
   145 // ---------------------------------------------------------
       
   146 // TPhoneCmdParamQuery::QueryPrompt
       
   147 // Returns the query dialog's prompt text
       
   148 // (other items were commented in a header).
       
   149 // ---------------------------------------------------------
       
   150 //
       
   151 EXPORT_C const TDesC& TPhoneCmdParamQuery::QueryPrompt() const
       
   152    {
       
   153    return iDialogPrompt;
       
   154    }
       
   155 
       
   156 // ---------------------------------------------------------
       
   157 // TPhoneCmdParamQuery::SetDefaultCba
       
   158 // Sets the default CBA resource id
       
   159 // (other items were commented in a header).
       
   160 // ---------------------------------------------------------
       
   161 //
       
   162 EXPORT_C void TPhoneCmdParamQuery::SetDefaultCba( TInt aCbaResourceId )
       
   163    {
       
   164    iDefaultCbaResourceId = aCbaResourceId;   
       
   165    }
       
   166 
       
   167 // ---------------------------------------------------------
       
   168 // TPhoneCmdParamQuery::DefaultCba
       
   169 // Returns the default CBA resource id
       
   170 // (other items were commented in a header).
       
   171 // ---------------------------------------------------------
       
   172 //
       
   173 EXPORT_C TInt TPhoneCmdParamQuery::DefaultCba() const
       
   174    {
       
   175    return iDefaultCbaResourceId;
       
   176    }
       
   177 
       
   178 // ---------------------------------------------------------
       
   179 // TPhoneCmdParamQuery::SetContentCba
       
   180 // Sets the content CBA resource id
       
   181 // (other items were commented in a header).
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 EXPORT_C void TPhoneCmdParamQuery::SetContentCba( TInt aCbaResourceId )
       
   185    {
       
   186    iContentCbaResourceId = aCbaResourceId;   
       
   187    }
       
   188 
       
   189 // ---------------------------------------------------------
       
   190 // TPhoneCmdParamQuery::ContentCba
       
   191 // Returns the content CBA resource id
       
   192 // (other items were commented in a header).
       
   193 // ---------------------------------------------------------
       
   194 //
       
   195 EXPORT_C TInt TPhoneCmdParamQuery::ContentCba() const
       
   196    {
       
   197    return iContentCbaResourceId;
       
   198    }
       
   199 
       
   200 // ---------------------------------------------------------
       
   201 // TPhoneCmdParamQuery::SetDataText
       
   202 // Sets the data text
       
   203 // (other items were commented in a header).
       
   204 // ---------------------------------------------------------
       
   205 //
       
   206 EXPORT_C void TPhoneCmdParamQuery::SetDataText( TDes* aDataText )
       
   207     {
       
   208     __ASSERT_DEBUG( aDataText, Panic( EPhoneUtilsParameterNotInitialized ) );
       
   209     iDataText = aDataText;   
       
   210     }
       
   211 
       
   212 // ---------------------------------------------------------
       
   213 // TPhoneCmdParamQuery::DataText
       
   214 // Returns the data text
       
   215 // (other items were commented in a header).
       
   216 // ---------------------------------------------------------
       
   217 //
       
   218 EXPORT_C TDes* TPhoneCmdParamQuery::DataText() const
       
   219     {
       
   220     return iDataText;
       
   221     }
       
   222    
       
   223 // ---------------------------------------------------------
       
   224 // TPhoneCmdParamQuery::SetQueryType
       
   225 // Sets the query type
       
   226 // (other items were commented in a header).
       
   227 // ---------------------------------------------------------
       
   228 //
       
   229 EXPORT_C void TPhoneCmdParamQuery::SetQueryType( TPhoneQueryType aQueryType )
       
   230     {
       
   231     iQueryType = aQueryType;        
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------
       
   235 // TPhoneCmdParamQuery::QueryType
       
   236 // Returns the query type
       
   237 // (other items were commented in a header).
       
   238 // ---------------------------------------------------------
       
   239 //
       
   240 EXPORT_C TPhoneQueryType TPhoneCmdParamQuery::QueryType() const
       
   241     {
       
   242     return iQueryType;    
       
   243     }
       
   244     
       
   245 // ---------------------------------------------------------
       
   246 // TPhoneCmdParamQuery::SetSendKeyEnabled
       
   247 // Sets the send key enabled status for the query
       
   248 // (other items were commented in a header).
       
   249 // ---------------------------------------------------------
       
   250 //
       
   251 EXPORT_C void TPhoneCmdParamQuery::SetSendKeyEnabled( TBool aSendKeyEnabled )
       
   252     {
       
   253     iSendKeyEnabled = aSendKeyEnabled;
       
   254     }
       
   255 
       
   256 // ---------------------------------------------------------
       
   257 // TPhoneCmdParamQuery::SendKeyEnabled
       
   258 // Returns the send key enabled status for the query
       
   259 // (other items were commented in a header).
       
   260 // ---------------------------------------------------------
       
   261 //
       
   262 EXPORT_C TBool TPhoneCmdParamQuery::SendKeyEnabled() const
       
   263     {
       
   264     return iSendKeyEnabled;    
       
   265     }
       
   266     
       
   267 // ---------------------------------------------------------
       
   268 // TPhoneCmdParamQuery::SetCommandParamId
       
   269 // Sets the query command param id
       
   270 // ---------------------------------------------------------
       
   271 //
       
   272 EXPORT_C void TPhoneCmdParamQuery::SetCommandParamId( TPhoneCommandParam::TPhoneParamId aParamId )
       
   273    {
       
   274    iParamId = aParamId;
       
   275    }
       
   276    
       
   277 // ---------------------------------------------------------
       
   278 // TPhoneCmdParamQuery::SetTimeOut
       
   279 // ---------------------------------------------------------
       
   280 //
       
   281 EXPORT_C void TPhoneCmdParamQuery::SetTimeOut( TInt aTimeOut )
       
   282     {
       
   283     iTimeOut = aTimeOut;
       
   284     }   
       
   285 
       
   286 // ---------------------------------------------------------
       
   287 // TPhoneCmdParamQuery::TimeOut
       
   288 // ---------------------------------------------------------
       
   289 //
       
   290 EXPORT_C TInt TPhoneCmdParamQuery::TimeOut() const
       
   291     {
       
   292     return iTimeOut; 
       
   293     }
       
   294 
       
   295 
       
   296 // ---------------------------------------------------------
       
   297 // TPhoneCmdParamQuery::SetTone
       
   298 // ---------------------------------------------------------
       
   299 //
       
   300 EXPORT_C void TPhoneCmdParamQuery::SetTone( TInt aTone )
       
   301     {
       
   302     __ASSERT_DEBUG( 0 <= aTone , Panic( EPhoneUtilsInvalidArgument ) );
       
   303     if ( 0 <= iTone )
       
   304         {
       
   305         iTone = aTone;
       
   306         }
       
   307     }
       
   308 
       
   309 
       
   310 // ---------------------------------------------------------
       
   311 // TPhoneCmdParamQuery::Tone
       
   312 // ---------------------------------------------------------
       
   313 //
       
   314 EXPORT_C TInt TPhoneCmdParamQuery::Tone() const
       
   315     {
       
   316     return iTone;
       
   317     }
       
   318 
       
   319 
       
   320 // ---------------------------------------------------------
       
   321 // TPhoneCmdParamQuery::SetCbaCommandMapping
       
   322 // ---------------------------------------------------------
       
   323 //
       
   324 EXPORT_C void TPhoneCmdParamQuery::SetCbaCommandMapping( 
       
   325         TInt aCbaCommandId, TInt aCustomCommandId )
       
   326     {
       
   327     TCbaCommandMapping unallocatedMapping = TCbaCommandMapping();
       
   328     TBool mappingCreated = EFalse;
       
   329     TInt maxNumOfMappings = iCbaCommandMappings.Count();
       
   330     
       
   331     for ( TInt i = 0; i < maxNumOfMappings && !mappingCreated; i++ )
       
   332         {
       
   333         if ( iCbaCommandMappings[i] == unallocatedMapping || 
       
   334              iCbaCommandMappings[i].CbaCommandId() == aCbaCommandId )
       
   335             {
       
   336             mappingCreated = ETrue;
       
   337             TCbaCommandMapping mapping( aCbaCommandId, aCustomCommandId );
       
   338             iCbaCommandMappings[i] = mapping;
       
   339             }
       
   340         }
       
   341     
       
   342     __ASSERT_DEBUG( mappingCreated, Panic( EPhoneUtilsIndexOutOfBounds ) );
       
   343     }
       
   344 
       
   345 
       
   346 // ---------------------------------------------------------
       
   347 // TPhoneCmdParamQuery::CbaCommandMapping
       
   348 // ---------------------------------------------------------
       
   349 //
       
   350 EXPORT_C TInt TPhoneCmdParamQuery::CbaCommandMapping( 
       
   351         TInt aCbaCommandId ) const
       
   352     {
       
   353     TInt maxNumOfMappings = iCbaCommandMappings.Count(); 
       
   354     for ( TInt i = 0; i < maxNumOfMappings; i++ )
       
   355         {
       
   356         if ( iCbaCommandMappings[i].CbaCommandId() == aCbaCommandId )
       
   357             {
       
   358             return iCbaCommandMappings[i].CustomCommandId();
       
   359             }
       
   360         }
       
   361     return aCbaCommandId;
       
   362     }
       
   363 
       
   364 
       
   365 // ---------------------------------------------------------
       
   366 // TPhoneCmdParamQuery::SetCustomCommandForTimeOut
       
   367 // ---------------------------------------------------------
       
   368 //
       
   369 EXPORT_C void TPhoneCmdParamQuery::SetCustomCommandForTimeOut( 
       
   370         TInt aCustomCommandId )
       
   371     {
       
   372     iCustomCmdForTimeOut = aCustomCommandId;
       
   373     }
       
   374 
       
   375 
       
   376 // ---------------------------------------------------------
       
   377 // TPhoneCmdParamQuery::GetCustomCommandForTimeOut
       
   378 // ---------------------------------------------------------
       
   379 //
       
   380 EXPORT_C TInt TPhoneCmdParamQuery::GetCustomCommandForTimeOut( 
       
   381         TInt& aCustomCommandId ) const
       
   382     {
       
   383     if ( KUninitializedTimeOutCmd == iCustomCmdForTimeOut )
       
   384         {
       
   385         return KErrNotFound;
       
   386         }
       
   387     else
       
   388         {
       
   389         aCustomCommandId = iCustomCmdForTimeOut;
       
   390         return KErrNone;
       
   391         }
       
   392     }
       
   393 
       
   394 
       
   395 // ---------------------------------------------------------
       
   396 // TPhoneCmdParamQuery::SetQueryCommandObserver
       
   397 // ---------------------------------------------------------
       
   398 //
       
   399 EXPORT_C void TPhoneCmdParamQuery::SetQueryCommandObserver( 
       
   400         MPhoneQueryCommandObserver& aObserver )
       
   401     {
       
   402     iCommandObserver = &aObserver;
       
   403     }
       
   404 
       
   405 
       
   406 // ---------------------------------------------------------
       
   407 // TPhoneCmdParamQuery::QueryCommandObserver
       
   408 // ---------------------------------------------------------
       
   409 //
       
   410 EXPORT_C MPhoneQueryCommandObserver* 
       
   411     TPhoneCmdParamQuery::QueryCommandObserver()
       
   412     {
       
   413     return iCommandObserver;
       
   414     }
       
   415 
       
   416 // ---------------------------------------------------------
       
   417 // TPhoneCmdParamQuery::SetItemTextArrayForListQuery
       
   418 // ---------------------------------------------------------
       
   419 //
       
   420 EXPORT_C void TPhoneCmdParamQuery::SetItemTextArrayForListQuery( 
       
   421         MDesCArray& aItemTextArray )
       
   422     {
       
   423     iItemTextArray = &aItemTextArray;
       
   424     }
       
   425 
       
   426 
       
   427 // ---------------------------------------------------------
       
   428 // TPhoneCmdParamQuery::ItemTextArrayForListQuery
       
   429 // ---------------------------------------------------------
       
   430 //
       
   431 EXPORT_C MDesCArray* TPhoneCmdParamQuery::ItemTextArrayForListQuery() const
       
   432     {
       
   433     return iItemTextArray;
       
   434     }
       
   435 
       
   436 //  End of File