00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "txti.h"
00010
00011
00012 #include <bautils.h>
00013 #include <coemain.h>
00014
00015
00016 #include <msvstd.hrh>
00017 #include <mtclbase.h>
00018 #include <mtmdef.hrh>
00019 #include <msvids.h>
00020 #include <msvuids.h>
00021 #include <mtmuidef.hrh>
00022 #include <stringloader.h>
00023 #include <AknsSkinInstance.h>
00024 #include <AknsUtils.h>
00025 #include <aknsconstants.h>
00026
00027 #include <txti.rsg>
00028 #include <txti.mbg>
00029
00030
00031 #include <akniconutils.h>
00032
00033 #include "txclient.h"
00034 #include "txtipan.h"
00035
00036
00037 #include "txut.h"
00038 #include "txtucmds.hrh"
00039 #include "../../Client/inc/txclient.h"
00040 #include "txtipan.h"
00041
00042
00043 #include <eikcore.rsg>
00044
00045 #ifdef __WINS__
00046 #pragma message("If you use an IDE, build from the command line first to create the bitmaps file and .mbg header")
00047 #endif
00048
00049
00050 const TInt KTxtiMtmUdNumberOfIconSets = 3;
00051 const TInt KTxtMtmArrayGranularity = 18;
00052
00053 _LIT(KTxtiMtmUdResourceFile,"TXTI.RSC");
00054 _LIT(KTxtiMtmUdBitmapFile,"TXTI.MIF");
00055 #ifdef __WINS__
00056
00057 _LIT(KTxtiMtmUdPath,"\\resource\\messaging\\");
00058 #else
00059 _LIT(KTxtiMtmUdPath,"c:\\resource\\messaging\\");
00060 #endif //WINS
00061
00062
00063
00064
00065 #define KUidMtmQueryCanCreateNewMsgValue 0x10008b24
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 enum TIcons
00077 {
00078 EMailRead,
00079 EMailUnread,
00080 EService
00081 };
00082
00083 EXPORT_C CTxtiMtmUiData* CTxtiMtmUiData::NewL(CRegisteredMtmDll& aRegisteredDll)
00084 {
00085 CTxtiMtmUiData* base=new(ELeave) CTxtiMtmUiData(aRegisteredDll);
00086 CleanupStack::PushL(base);
00087 base->TxtConstructL();
00088 CleanupStack::Pop(base);
00089 return base;
00090 }
00091
00092 void CTxtiMtmUiData::TxtConstructL()
00093 {
00094
00095 iIconArrays = new (ELeave) CArrayPtrSeg<CBitmapArray>(KTxtMtmArrayGranularity);
00096 iMtmSpecificFunctions = new (ELeave) CArrayFixFlat<TMtmUiFunction>(KTxtMtmArrayGranularity);
00097
00098
00099 TFileName resourceFileName;
00100
00101 TxtUtils::FindFileL(KTxtiMtmUdResourceFile, KTxtiMtmUdPath, resourceFileName);
00102 iResourceFileName = resourceFileName.AllocL();
00103
00104
00105
00106 BaflUtils::NearestLanguageFile(iCoeEnv->FsSession(), resourceFileName);
00107
00108
00109 iNewResourceFileOffset=iCoeEnv->AddResourceFileL(resourceFileName);
00110
00111
00112 PopulateArraysL();
00113 }
00114
00115
00116
00117 void CTxtiMtmUiData::TxtCreateBitmapsL(const TDesC& aBitmapFile)
00118 {
00119 CFbsBitmap* bitmap;
00120 CFbsBitmap* bitmapMask;
00121
00122 TBool found = ETrue;
00123
00124 for( TInt i = EMbmTxtiRead;
00125 i < EMbmTxtiLastElement;
00126 i++ )
00127 {
00128 found = ETrue;
00129 switch( i )
00130 {
00131
00132 case EMbmTxtiRead:
00133 break;
00134 case EMbmTxtiUnread:
00135 break;
00136 case EMbmTxtiMailbox:
00137 break;
00138 default:
00139 found = EFalse;
00140 break;
00141 }
00142 if( found )
00143 {
00144 CArrayPtrFlat<CFbsBitmap>* array =
00145 new (ELeave) CArrayPtrFlat<CFbsBitmap>( KTxtMtmArrayGranularity );
00146 CleanupStack::PushL( array );
00147
00148 array->SetReserveL( KTxtMtmArrayGranularity );
00149 TInt err=0;
00150 TRAP(err, AknIconUtils::CreateIconL(bitmap, bitmapMask,
00151 aBitmapFile, i, i + 1 ));
00152 array->AppendL( bitmap );
00153 bitmap = 0;
00154 array->AppendL( bitmapMask );
00155 bitmapMask = 0;
00156 iIconArrays->AppendL( array );
00157 CleanupStack::Pop( array );
00158 }
00159 }
00160 return;
00161 }
00162
00163
00164
00165 CTxtiMtmUiData::~CTxtiMtmUiData()
00166 {
00167
00168 if (iNewResourceFileOffset != 0)
00169 iCoeEnv->DeleteResourceFile(iNewResourceFileOffset);
00170 delete iResourceFileName;
00171
00172
00173
00174
00175 }
00176
00177
00178
00179
00180 void CTxtiMtmUiData::PopulateArraysL()
00181 {
00182
00183 ReadFunctionsFromResourceFileL(R_TEXTUD_FUNCTION_ARRAY);
00184
00185
00186 TFileName bitmapFileName;
00187 TxtUtils::FindFileL(KTxtiMtmUdBitmapFile, KTxtiMtmUdPath, bitmapFileName);
00188
00189 TxtCreateBitmapsL(bitmapFileName);
00190 }
00191
00192
00193
00194
00195 CTxtiMtmUiData::CTxtiMtmUiData(CRegisteredMtmDll& aRegisteredDll)
00196 : CBaseMtmUiData(aRegisteredDll)
00197 {
00198 }
00199
00200
00201 void CTxtiMtmUiData::GetResourceFileName(TFileName& aFileName) const
00202
00203 {
00204 aFileName=*iResourceFileName;
00205 }
00206
00207
00208
00209
00210
00211
00212
00213
00214 TInt CTxtiMtmUiData::OperationSupportedL(TInt aOperationId, const TMsvEntry& aContext) const
00215 {
00216 TInt aReasonResourceId=0;
00217
00218 if (aContext.iMtm!=KUidMsgTypeText)
00219 return R_TEXTUD_NOT_SUPPORTED;
00220
00221 const TBool isMessage = (aContext.iType==KUidMsvMessageEntry);
00222 const TBool isService = (aContext.iType==KUidMsvServiceEntry);
00223
00224 if (aOperationId==ETxtuCommandRefreshMBox)
00225 {
00226
00227 if (!isService)
00228 aReasonResourceId=R_TEXTUD_ONLY_REFRESH_SERVICES;
00229 }
00230 else if (aOperationId==ETxtuCommandMessage)
00231 {
00232
00233 if ( (!isMessage) || (aContext.iServiceId != KMsvLocalServiceIndexEntryId) )
00234 aReasonResourceId=R_TEXTUD_ONLY_MESSAGES;
00235 }
00236 return aReasonResourceId;
00237 }
00238
00239
00240 TInt CTxtiMtmUiData::QueryCapability(TUid aCapability, TInt& aResponse) const
00241
00242 {
00243 switch (aCapability.iUid)
00244 {
00245
00246 case KUidMtmQueryMaxBodySizeValue:
00247 aResponse=KMaxTextMessageSize;
00248 break;
00249 case KUidMtmQueryMaxTotalMsgSizeValue:
00250 aResponse=KMaxTextMessageSize;
00251 break;
00252
00253
00254
00255 case KUidMtmQuerySupportedBodyValue:
00256 case KUidMtmQueryOffLineAllowedValue:
00257 case KUidMtmQueryCanReceiveMsgValue:
00258 case KUidMtmQueryCanSendMsgValue:
00259 case KUidMtmQueryCanCreateNewMsgValue:
00260 aResponse=0;
00261 break;
00262
00263 default:
00264 return KErrNotSupported;
00265 };
00266 return KErrNone;
00267 }
00268
00269
00270 const CBaseMtmUiData::CBitmapArray& CTxtiMtmUiData::ContextIcon(const TMsvEntry& aContext, TInt ) const
00271 {
00272 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00273 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdNoIconForAttachment));
00274
00275 TInt retIndex=EService;
00276
00277 if (aContext.iType == KUidMsvServiceEntry ||aContext.iType == KUidMsvFolderEntry )
00278 {
00279 retIndex=EService;
00280 }
00281 else
00282 {
00283
00284
00285 if (aContext.iType == KUidMsvMessageEntry)
00286 retIndex=aContext.Unread() ? EMailUnread : EMailRead;
00287 }
00288
00289 return *(iIconArrays->At(retIndex));
00290 }
00291
00292
00293
00294
00295
00296 TBool CTxtiMtmUiData::CanOpenEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const
00297 {
00298 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00299 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00300
00301 aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
00302 if ( aContext.iType != KUidMsvMessageEntry )
00303 {
00304 aReasonResourceId=R_TEXTUD_ONLY_MESSAGES;
00305 return EFalse;
00306 }
00307 else
00308 return ETrue;
00309 }
00310
00311
00312 TBool CTxtiMtmUiData::CanCloseEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const
00313 {
00314 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00315 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00316
00317 aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
00318 if ( aContext.iType != KUidMsvMessageEntry )
00319 {
00320 aReasonResourceId=R_TEXTUD_ONLY_MESSAGES;
00321 return EFalse;
00322 }
00323 else
00324 return ETrue;
00325 }
00326
00327
00328 TBool CTxtiMtmUiData::CanViewEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const
00329 {
00330 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00331 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00332
00333 aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
00334 if ( aContext.iType != KUidMsvMessageEntry )
00335 {
00336 aReasonResourceId=R_TEXTUD_ONLY_MESSAGES;
00337 return EFalse;
00338 }
00339 else
00340 return ETrue;
00341 }
00342
00343
00344 TBool CTxtiMtmUiData::CanEditEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const
00345 {
00346 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00347 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00348
00349 aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
00350 if ( aContext.iType == KUidMsvFolderEntry )
00351 {
00352 aReasonResourceId=R_TEXTUD_CAN_NOT_EDIT_FOLDERS;
00353 return EFalse;
00354 }
00355 else
00356 return ETrue;
00357 }
00358
00359
00360 TBool CTxtiMtmUiData::CanDeleteFromEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const
00361 {
00362 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00363 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00364
00365 aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
00366 return EFalse;
00367 }
00368
00369
00370 TBool CTxtiMtmUiData::CanCopyMoveToEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const
00371 {
00372 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00373 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00374
00375 aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
00376 return EFalse;
00377 }
00378
00379
00380 TBool CTxtiMtmUiData::CanCopyMoveFromEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const
00381 {
00382 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00383 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00384
00385 aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
00386 return EFalse;
00387 }
00388
00389
00390 TBool CTxtiMtmUiData::CanReplyToEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const
00391
00392
00393
00394 {
00395 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00396 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00397
00398 aReasonResourceId=R_TEXTUD_NOT_SUPPORTED;
00399 return EFalse;
00400 }
00401
00402
00403 TBool CTxtiMtmUiData::CanForwardEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const
00404
00405
00406
00407 {
00408 __ASSERT_ALWAYS(aContext.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00409 __ASSERT_ALWAYS(aContext.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00410
00411 aReasonResourceId=R_TEXTUD_NOT_SUPPORTED;
00412 return EFalse;
00413 }
00414
00415
00416 TBool CTxtiMtmUiData::CanCreateEntryL(const TMsvEntry& aParent, TMsvEntry& aNewEntry,
00417 TInt& aReasonResourceId) const
00418 {
00419 __ASSERT_ALWAYS(aNewEntry.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00420 __ASSERT_ALWAYS(aNewEntry.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));
00421
00422 aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
00423
00424 if (aNewEntry.iType == KUidMsvServiceEntry)
00425 return (aParent.Id() == KMsvRootIndexEntryIdValue);
00426
00427
00428 if (aNewEntry.iType == KUidMsvMessageEntry)
00429 return (aParent.iMtm.iUid == KMsvLocalServiceIndexEntryIdValue);
00430
00431 return EFalse;
00432 }
00433
00434 TBool CTxtiMtmUiData::CanDeleteServiceL(const TMsvEntry& aService, TInt& aReasonResourceId)const
00435 {
00436 __ASSERT_ALWAYS(aService.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
00437
00438 aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
00439 return EFalse;
00440 }
00441
00442 TBool CTxtiMtmUiData::CanCancelL(const TMsvEntry& , TInt& ) const
00443 {
00444 return EFalse;
00445 }
00446
00447 HBufC* CTxtiMtmUiData::StatusTextL(const TMsvEntry& ) const
00448 {
00449 return StringLoader::LoadL(R_TEXTUD_STATUS_TEXT, iCoeEnv );
00450 }