phoneapp/phoneuiutils/src/tphonecmdparamquery.cpp
changeset 0 5f000ab63145
child 21 92ab7f8d0eab
child 61 41a7f70b3818
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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    	__ASSERT_DEBUG( iDataText, Panic( EPhoneUtilsInvariant ) );
       
   221    	return iDataText;
       
   222    	}
       
   223    
       
   224 // ---------------------------------------------------------
       
   225 // TPhoneCmdParamQuery::SetQueryType
       
   226 // Sets the query type
       
   227 // (other items were commented in a header).
       
   228 // ---------------------------------------------------------
       
   229 //
       
   230 EXPORT_C void TPhoneCmdParamQuery::SetQueryType( TPhoneQueryType aQueryType )
       
   231     {
       
   232     iQueryType = aQueryType;        
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------
       
   236 // TPhoneCmdParamQuery::QueryType
       
   237 // Returns the query type
       
   238 // (other items were commented in a header).
       
   239 // ---------------------------------------------------------
       
   240 //
       
   241 EXPORT_C TPhoneQueryType TPhoneCmdParamQuery::QueryType() const
       
   242     {
       
   243     return iQueryType;    
       
   244     }
       
   245     
       
   246 // ---------------------------------------------------------
       
   247 // TPhoneCmdParamQuery::SetSendKeyEnabled
       
   248 // Sets the send key enabled status for the query
       
   249 // (other items were commented in a header).
       
   250 // ---------------------------------------------------------
       
   251 //
       
   252 EXPORT_C void TPhoneCmdParamQuery::SetSendKeyEnabled( TBool aSendKeyEnabled )
       
   253     {
       
   254     iSendKeyEnabled = aSendKeyEnabled;
       
   255     }
       
   256 
       
   257 // ---------------------------------------------------------
       
   258 // TPhoneCmdParamQuery::SendKeyEnabled
       
   259 // Returns the send key enabled status for the query
       
   260 // (other items were commented in a header).
       
   261 // ---------------------------------------------------------
       
   262 //
       
   263 EXPORT_C TBool TPhoneCmdParamQuery::SendKeyEnabled() const
       
   264     {
       
   265     return iSendKeyEnabled;    
       
   266     }
       
   267     
       
   268 // ---------------------------------------------------------
       
   269 // TPhoneCmdParamQuery::SetCommandParamId
       
   270 // Sets the query command param id
       
   271 // ---------------------------------------------------------
       
   272 //
       
   273 EXPORT_C void TPhoneCmdParamQuery::SetCommandParamId( TPhoneCommandParam::TPhoneParamId aParamId )
       
   274    {
       
   275    iParamId = aParamId;
       
   276    }
       
   277    
       
   278 // ---------------------------------------------------------
       
   279 // TPhoneCmdParamQuery::SetTimeOut
       
   280 // ---------------------------------------------------------
       
   281 //
       
   282 EXPORT_C void TPhoneCmdParamQuery::SetTimeOut( TInt aTimeOut )
       
   283     {
       
   284     iTimeOut = aTimeOut;
       
   285     }   
       
   286 
       
   287 // ---------------------------------------------------------
       
   288 // TPhoneCmdParamQuery::TimeOut
       
   289 // ---------------------------------------------------------
       
   290 //
       
   291 EXPORT_C TInt TPhoneCmdParamQuery::TimeOut() const
       
   292     {
       
   293     return iTimeOut; 
       
   294     }
       
   295 
       
   296 
       
   297 // ---------------------------------------------------------
       
   298 // TPhoneCmdParamQuery::SetTone
       
   299 // ---------------------------------------------------------
       
   300 //
       
   301 EXPORT_C void TPhoneCmdParamQuery::SetTone( TInt aTone )
       
   302     {
       
   303     __ASSERT_DEBUG( 0 <= aTone , Panic( EPhoneUtilsInvalidArgument ) );
       
   304     if ( 0 <= iTone )
       
   305         {
       
   306         iTone = aTone;
       
   307         }
       
   308     }
       
   309 
       
   310 
       
   311 // ---------------------------------------------------------
       
   312 // TPhoneCmdParamQuery::Tone
       
   313 // ---------------------------------------------------------
       
   314 //
       
   315 EXPORT_C TInt TPhoneCmdParamQuery::Tone() const
       
   316     {
       
   317     return iTone;
       
   318     }
       
   319 
       
   320 
       
   321 // ---------------------------------------------------------
       
   322 // TPhoneCmdParamQuery::SetCbaCommandMapping
       
   323 // ---------------------------------------------------------
       
   324 //
       
   325 EXPORT_C void TPhoneCmdParamQuery::SetCbaCommandMapping( 
       
   326         TInt aCbaCommandId, TInt aCustomCommandId )
       
   327     {
       
   328     TCbaCommandMapping unallocatedMapping = TCbaCommandMapping();
       
   329     TBool mappingCreated = EFalse;
       
   330     TInt maxNumOfMappings = iCbaCommandMappings.Count();
       
   331     
       
   332     for ( TInt i = 0; i < maxNumOfMappings && !mappingCreated; i++ )
       
   333         {
       
   334         if ( iCbaCommandMappings[i] == unallocatedMapping || 
       
   335              iCbaCommandMappings[i].CbaCommandId() == aCbaCommandId )
       
   336             {
       
   337             mappingCreated = ETrue;
       
   338             TCbaCommandMapping mapping( aCbaCommandId, aCustomCommandId );
       
   339             iCbaCommandMappings[i] = mapping;
       
   340             }
       
   341         }
       
   342     
       
   343     __ASSERT_DEBUG( mappingCreated, Panic( EPhoneUtilsIndexOutOfBounds ) );
       
   344     }
       
   345 
       
   346 
       
   347 // ---------------------------------------------------------
       
   348 // TPhoneCmdParamQuery::CbaCommandMapping
       
   349 // ---------------------------------------------------------
       
   350 //
       
   351 EXPORT_C TInt TPhoneCmdParamQuery::CbaCommandMapping( 
       
   352         TInt aCbaCommandId ) const
       
   353     {
       
   354     TInt maxNumOfMappings = iCbaCommandMappings.Count(); 
       
   355     for ( TInt i = 0; i < maxNumOfMappings; i++ )
       
   356         {
       
   357         if ( iCbaCommandMappings[i].CbaCommandId() == aCbaCommandId )
       
   358             {
       
   359             return iCbaCommandMappings[i].CustomCommandId();
       
   360             }
       
   361         }
       
   362     return aCbaCommandId;
       
   363     }
       
   364 
       
   365 
       
   366 // ---------------------------------------------------------
       
   367 // TPhoneCmdParamQuery::SetCustomCommandForTimeOut
       
   368 // ---------------------------------------------------------
       
   369 //
       
   370 EXPORT_C void TPhoneCmdParamQuery::SetCustomCommandForTimeOut( 
       
   371         TInt aCustomCommandId )
       
   372     {
       
   373     iCustomCmdForTimeOut = aCustomCommandId;
       
   374     }
       
   375 
       
   376 
       
   377 // ---------------------------------------------------------
       
   378 // TPhoneCmdParamQuery::GetCustomCommandForTimeOut
       
   379 // ---------------------------------------------------------
       
   380 //
       
   381 EXPORT_C TInt TPhoneCmdParamQuery::GetCustomCommandForTimeOut( 
       
   382         TInt& aCustomCommandId ) const
       
   383     {
       
   384     if ( KUninitializedTimeOutCmd == iCustomCmdForTimeOut )
       
   385         {
       
   386         return KErrNotFound;
       
   387         }
       
   388     else
       
   389         {
       
   390         aCustomCommandId = iCustomCmdForTimeOut;
       
   391         return KErrNone;
       
   392         }
       
   393     }
       
   394 
       
   395 
       
   396 // ---------------------------------------------------------
       
   397 // TPhoneCmdParamQuery::SetQueryCommandObserver
       
   398 // ---------------------------------------------------------
       
   399 //
       
   400 EXPORT_C void TPhoneCmdParamQuery::SetQueryCommandObserver( 
       
   401         MPhoneQueryCommandObserver& aObserver )
       
   402     {
       
   403     iCommandObserver = &aObserver;
       
   404     }
       
   405 
       
   406 
       
   407 // ---------------------------------------------------------
       
   408 // TPhoneCmdParamQuery::QueryCommandObserver
       
   409 // ---------------------------------------------------------
       
   410 //
       
   411 EXPORT_C MPhoneQueryCommandObserver* 
       
   412     TPhoneCmdParamQuery::QueryCommandObserver()
       
   413     {
       
   414     return iCommandObserver;
       
   415     }
       
   416 
       
   417 // ---------------------------------------------------------
       
   418 // TPhoneCmdParamQuery::SetItemTextArrayForListQuery
       
   419 // ---------------------------------------------------------
       
   420 //
       
   421 EXPORT_C void TPhoneCmdParamQuery::SetItemTextArrayForListQuery( 
       
   422         MDesCArray& aItemTextArray )
       
   423     {
       
   424     iItemTextArray = &aItemTextArray;
       
   425     }
       
   426 
       
   427 
       
   428 // ---------------------------------------------------------
       
   429 // TPhoneCmdParamQuery::ItemTextArrayForListQuery
       
   430 // ---------------------------------------------------------
       
   431 //
       
   432 EXPORT_C MDesCArray* TPhoneCmdParamQuery::ItemTextArrayForListQuery() const
       
   433     {
       
   434     return iItemTextArray;
       
   435     }
       
   436 
       
   437 //  End of File