16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include "obexutilsmessagehandler.h" |
20 #include "obexutilsmessagehandler.h" |
21 #include "obexutilsuilayer.h" |
|
22 #include "obexutilsdebug.h" |
21 #include "obexutilsdebug.h" |
23 #include "obexutilsentryhandler.h" |
22 #include "obexutilsentryhandler.h" |
24 |
23 |
25 #include <msvids.h> |
24 #include <msvids.h> |
26 #include <msvuids.h> |
25 #include <msvuids.h> |
27 #include <apgcli.h> |
26 #include <apgcli.h> |
28 #include <txtrich.h> |
27 #include <txtrich.h> |
29 |
28 |
30 #include <biouids.h> |
29 #include <biouids.h> |
31 #include <Obexutils.rsg> |
|
32 #include <bautils.h> |
30 #include <bautils.h> |
33 |
31 |
34 #include <e32property.h> |
32 #include <e32property.h> |
35 #include <UikonInternalPSKeys.h> |
33 #include <UikonInternalPSKeys.h> |
36 |
34 |
48 #endif // __BT_SAP |
46 #endif // __BT_SAP |
49 |
47 |
50 // CONSTANT |
48 // CONSTANT |
51 const TInt KFFSBelowCritical = -2; |
49 const TInt KFFSBelowCritical = -2; |
52 const TInt KRenameOffSet = 4 ; |
50 const TInt KRenameOffSet = 4 ; |
|
51 |
|
52 // todo @ QT migration: take official definition from Messaging at app layer (btmsgtypeuid.h) |
|
53 const TUid KUidMsgTypeBt = {0x10009ED5}; |
|
54 |
|
55 const TInt KObexUtilsMaxCharToFromField = 256; |
|
56 |
53 // ============================= LOCAL FUNCTIONS =============================== |
57 // ============================= LOCAL FUNCTIONS =============================== |
54 |
58 |
55 // ----------------------------------------------------------------------------- |
59 // ----------------------------------------------------------------------------- |
56 // RemoveObexBuffer Removes Obex buffer object. |
60 // RemoveObexBuffer Removes Obex buffer object. |
57 // ----------------------------------------------------------------------------- |
61 // ----------------------------------------------------------------------------- |
466 CMsvEntry* inbox; |
470 CMsvEntry* inbox; |
467 CreateMsvSessionLC(sessionObs, msvSession, inbox, KMsvGlobalInBoxIndexEntryId); |
471 CreateMsvSessionLC(sessionObs, msvSession, inbox, KMsvGlobalInBoxIndexEntryId); |
468 // 1st, 2nd, 3rd push |
472 // 1st, 2nd, 3rd push |
469 |
473 |
470 TBuf<KObexUtilsMaxCharToFromField> toFrom; |
474 TBuf<KObexUtilsMaxCharToFromField> toFrom; |
471 TInt resourceId; |
475 |
472 |
476 // todo @ QT migration: load from string id for localization |
473 if (aMtmId == KUidMsgTypeBt) |
477 if (aMtmId == KUidMsgTypeBt) |
474 { |
478 { |
475 resourceId = R_BT_TO_FROM_IN_INBOX; |
479 _LIT(KBluetoothMsg, "Bluetooth message"); |
|
480 toFrom.Copy(KBluetoothMsg); |
476 } |
481 } |
477 else |
482 else |
478 { |
483 { |
479 resourceId = R_IR_TO_FROM_IN_INBOX; |
484 _LIT(KInfraredMsg, "Infrared message"); |
480 } |
485 toFrom.Copy(KInfraredMsg); |
481 |
486 } |
482 TObexUtilsUiLayer::ReadResourceL( toFrom, resourceId ); |
|
483 |
487 |
484 TMsvEntry parentTEntry; |
488 TMsvEntry parentTEntry; |
485 parentTEntry.iMtm = aMtmId; |
489 parentTEntry.iMtm = aMtmId; |
486 parentTEntry.SetVisible(EFalse); // Make invisible.. |
490 parentTEntry.SetVisible(EFalse); // Make invisible.. |
487 parentTEntry.SetUnread(ETrue); |
491 parentTEntry.SetUnread(ETrue); |
833 CMsvEntry* inbox; |
837 CMsvEntry* inbox; |
834 CreateMsvSessionLC(sessionObs, msvSession, inbox, KMsvGlobalInBoxIndexEntryId); |
838 CreateMsvSessionLC(sessionObs, msvSession, inbox, KMsvGlobalInBoxIndexEntryId); |
835 // 1st, 2nd, 3rd push |
839 // 1st, 2nd, 3rd push |
836 |
840 |
837 TBuf<KObexUtilsMaxCharToFromField> toFrom; |
841 TBuf<KObexUtilsMaxCharToFromField> toFrom; |
838 TInt resourceId; |
842 |
839 |
843 // todo @ QT migration: load from string id for localization |
840 if (aMtmId == KUidMsgTypeBt) |
844 if (aMtmId == KUidMsgTypeBt) |
841 { |
845 { |
842 resourceId = R_BT_TO_FROM_IN_INBOX; |
846 _LIT(KBluetoothMsg, "Bluetooth message"); |
|
847 toFrom.Copy(KBluetoothMsg); |
843 } |
848 } |
844 else |
849 else |
845 { |
850 { |
846 resourceId = R_IR_TO_FROM_IN_INBOX; |
851 _LIT(KInfraredMsg, "Infrared message"); |
847 } |
852 toFrom.Copy(KInfraredMsg); |
848 // NOTE: toFrom will be updated to Bluetooth sender's name |
853 } |
849 // |
854 |
850 TObexUtilsUiLayer::ReadResourceL( toFrom, resourceId ); // read the toForm ( will be updated to sender's bt name in the future ) |
855 // NOTE: toFrom will be updated to Bluetooth sender's bt name in the future. |
851 |
856 |
852 TMsvEntry parentTEntry; |
857 TMsvEntry parentTEntry; |
853 parentTEntry.iMtm = aMtmId; |
858 parentTEntry.iMtm = aMtmId; |
854 parentTEntry.SetVisible(EFalse); // Make invisible.. |
859 parentTEntry.SetVisible(EFalse); // Make invisible.. |
855 parentTEntry.SetUnread(ETrue); // Set msg to Unread |
860 parentTEntry.SetUnread(ETrue); // Set msg to Unread |
998 if (bioDB) // bio message |
1003 if (bioDB) // bio message |
999 { |
1004 { |
1000 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() BIO")); |
1005 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() BIO")); |
1001 |
1006 |
1002 RFile file; |
1007 RFile file; |
1003 User::LeaveIfError(file.Open(fsSess,aFullName,EFileRead)); |
1008 User::LeaveIfError(file.Open(fsSess,aFullName,EFileShareReadersOnly)); |
1004 TReceivedData receivedData; |
1009 TReceivedData receivedData; |
1005 receivedData.bytesReceived = fileEntry.iSize; |
1010 receivedData.bytesReceived = fileEntry.iSize; |
1006 receivedData.recTime = fileEntry.iModified; |
1011 receivedData.recTime = fileEntry.iModified; |
1007 receivedData.msgName = fileNameParser.Name(); |
1012 receivedData.msgName = fileNameParser.Name(); |
1008 |
1013 |
1145 FLOG(_L("[OBEXUTILS]\t MakeValidFileName()")); |
1150 FLOG(_L("[OBEXUTILS]\t MakeValidFileName()")); |
1146 |
1151 |
1147 TParse fileParse; |
1152 TParse fileParse; |
1148 fileParse.Set(aFileName, NULL, NULL); |
1153 fileParse.Set(aFileName, NULL, NULL); |
1149 |
1154 |
1150 TBool nameempty = ETrue; |
|
1151 if (fileParse.NameOrExtPresent()) |
1155 if (fileParse.NameOrExtPresent()) |
1152 { |
1156 { |
1153 aFileName = fileParse.NameAndExt(); |
1157 aFileName = fileParse.NameAndExt(); |
1154 nameempty=EFalse; |
|
1155 TText badChar; |
1158 TText badChar; |
1156 TInt nameLength = aFileName.Length(); |
1159 TInt nameLength = aFileName.Length(); |
1157 |
1160 |
1158 while ( !aFileSession.IsValidName(aFileName, badChar) ) |
1161 while ( !aFileSession.IsValidName(aFileName, badChar) ) |
1159 { |
1162 { |
1172 { |
1175 { |
1173 break; |
1176 break; |
1174 } |
1177 } |
1175 } |
1178 } |
1176 } |
1179 } |
1177 |
|
1178 // Did we delete all the characters? If so then we must have some filename |
|
1179 if ( aFileName.Length() == 0 || nameempty ) |
|
1180 { |
|
1181 TInt resourceId = R_NAME_FOR_INVALID_FILE; |
|
1182 TRAPD( retVal, TObexUtilsUiLayer::ReadResourceL( aFileName, resourceId ) ); |
|
1183 if (retVal != KErrNone) |
|
1184 { |
|
1185 FLOG(_L("TObexUtilsMessageHandler::MakeValidFileName failed.")); |
|
1186 } |
|
1187 } |
|
1188 |
|
1189 FLOG(_L("[OBEXUTILS]\t MakeValidFileName() completed")); |
1180 FLOG(_L("[OBEXUTILS]\t MakeValidFileName() completed")); |
1190 } |
1181 } |
1191 |
1182 |
1192 // ----------------------------------------------------------------------------- |
1183 // ----------------------------------------------------------------------------- |
1193 // TObexUtilsMessageHandler::CreateOutboxEntryL |
1184 // TObexUtilsMessageHandler::CreateOutboxEntryL |
1194 // ----------------------------------------------------------------------------- |
1185 // ----------------------------------------------------------------------------- |
1195 // |
1186 // |
1196 EXPORT_C TMsvId TObexUtilsMessageHandler::CreateOutboxEntryL( |
1187 EXPORT_C TMsvId TObexUtilsMessageHandler::CreateOutboxEntryL( |
1197 const TUid& aMtm, // Message type id |
1188 const TUid& aMtm, // Message type id |
1198 const TInt& aResourceID ) // Resource id for the message entry text |
1189 //todo need to check whether to use the textmap id or send as a string here |
|
1190 const TInt& /*aResourceID*/ ) // Resource id for the message entry text |
1199 { |
1191 { |
1200 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::CreateOutboxEntryL()")); |
1192 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::CreateOutboxEntryL()")); |
1201 |
1193 |
1202 CDummySessionObserver* sessionObs; |
1194 CDummySessionObserver* sessionObs; |
1203 CMsvSession* msvSession; |
1195 CMsvSession* msvSession; |
1204 CMsvEntry* outBoxEntry; |
1196 CMsvEntry* outBoxEntry; |
1205 CreateMsvSessionLC(sessionObs, msvSession, outBoxEntry, KMsvGlobalOutBoxIndexEntryId); |
1197 CreateMsvSessionLC(sessionObs, msvSession, outBoxEntry, KMsvGlobalOutBoxIndexEntryId); |
1206 // 1st, 2nd, 3rd push |
1198 // 1st, 2nd, 3rd push |
1207 |
1199 |
1208 TBuf<KObexUtilsMaxCharToFromField> toFrom; |
1200 TBuf<KObexUtilsMaxCharToFromField> toFrom; |
1209 TObexUtilsUiLayer::ReadResourceL( toFrom, aResourceID ); |
1201 // TObexUtilsUiLayer::ReadResourceL( toFrom, aResourceID ); |
|
1202 //todo need to change the string constant to orbit localisation file |
|
1203 toFrom.Copy(_L("Bluetooth message")); |
1210 |
1204 |
1211 // Message entry fields |
1205 // Message entry fields |
1212 TMsvEntry newTEntry; |
1206 TMsvEntry newTEntry; |
1213 newTEntry.SetVisible( ETrue ); // Make visible |
1207 newTEntry.SetVisible( ETrue ); // Make visible |
1214 newTEntry.SetInPreparation( ETrue ); // and in preparation to make sure gets cleaned up on errors. |
1208 newTEntry.SetInPreparation( ETrue ); // and in preparation to make sure gets cleaned up on errors. |