messagingapp/msgnotifications/msgindicatorplugin/src/msgindicator_p.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
    22 #include "msgindicator_p.h"  
    22 #include "msgindicator_p.h"  
    23 #include "msgindicator.h"
    23 #include "msgindicator.h"
    24 #include "debugtraces.h"
    24 #include "debugtraces.h"
    25 #include "s60qconversions.h"
    25 #include "s60qconversions.h"
    26 
    26 
       
    27 #define LOC_RECEIVED_FILES hbTrId("Received Files")
       
    28 
    27 // ----------------------------------------------------------------------------
    29 // ----------------------------------------------------------------------------
    28 // MsgIndicatorPrivate::MsgIndicatorPrivate
    30 // MsgIndicatorPrivate::MsgIndicatorPrivate
    29 // @see MsgIndicatorPrivate.h
    31 // @see MsgIndicatorPrivate.h
    30 // ----------------------------------------------------------------------------
    32 // ----------------------------------------------------------------------------
    31 MsgIndicatorPrivate::MsgIndicatorPrivate(MsgIndicator* inidcator):
    33 MsgIndicatorPrivate::MsgIndicatorPrivate(MsgIndicator* inidcator) :
    32 	q_ptr(inidcator),mCvServer(NULL)
    34     q_ptr(inidcator), mCvServer(NULL)
    33     {
    35 {
    34     TRAP_IGNORE(initL());
    36     TRAP_IGNORE(initL());
    35     }
    37 }
    36 
    38 
    37 // ----------------------------------------------------------------------------
    39 // ----------------------------------------------------------------------------
    38 // MsgIndicatorPrivate::~MsgIndicatorPrivate
    40 // MsgIndicatorPrivate::~MsgIndicatorPrivate
    39 // @see MsgIndicatorPrivate.h
    41 // @see MsgIndicatorPrivate.h
    40 // ----------------------------------------------------------------------------
    42 // ----------------------------------------------------------------------------
    41 MsgIndicatorPrivate::~MsgIndicatorPrivate()
    43 MsgIndicatorPrivate::~MsgIndicatorPrivate()
    42     {
    44 {
    43     if(mCvServer)
    45     if (mCvServer) {
    44         {
       
    45         delete mCvServer;
    46         delete mCvServer;
    46         mCvServer = NULL;
    47         mCvServer = NULL;
    47         }
       
    48     }
    48     }
       
    49 }
    49 
    50 
    50 // ----------------------------------------------------------------------------
    51 // ----------------------------------------------------------------------------
    51 // MsgIndicatorPrivate::initL()
    52 // MsgIndicatorPrivate::initL()
    52 // @see MsgIndicatorPrivate.h
    53 // @see MsgIndicatorPrivate.h
    53 // ----------------------------------------------------------------------------
    54 // ----------------------------------------------------------------------------
    54 void MsgIndicatorPrivate::initL()
    55 void MsgIndicatorPrivate::initL()
    55     {
    56 {
    56     mCvServer = CCSRequestHandler::NewL();
    57     mCvServer = CCSRequestHandler::NewL();
    57     }
    58 }
    58 
    59 
    59 // ----------------------------------------------------------------------------
    60 // ----------------------------------------------------------------------------
    60 // MsgIndicatorPrivate::getIndicatorInfo
    61 // MsgIndicatorPrivate::getIndicatorInfo
    61 // @see MsgIndicatorPrivate.h
    62 // @see MsgIndicatorPrivate.h
    62 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
    63 void MsgIndicatorPrivate::getIndicatorInfo(IndicatorData& indicatorData)
    64 void MsgIndicatorPrivate::getIndicatorInfo(MsgInfo& indicatorData)
    64     {
    65 {
    65     TRAP_IGNORE(getIndicatorInfoL(indicatorData));
    66     TRAP_IGNORE(getIndicatorInfoL(indicatorData));
    66     }
    67 }
    67     
    68 
    68 // ----------------------------------------------------------------------------
    69 // ----------------------------------------------------------------------------
    69 // MsgIndicatorPrivate::getIndicatorInfoL
    70 // MsgIndicatorPrivate::getIndicatorInfoL
    70 // @see MsgIndicatorPrivate.h
    71 // @see MsgIndicatorPrivate.h
    71 // ----------------------------------------------------------------------------
    72 // ----------------------------------------------------------------------------
    72 void MsgIndicatorPrivate::getIndicatorInfoL(IndicatorData& indicatorData)
    73 void MsgIndicatorPrivate::getIndicatorInfoL(MsgInfo& indicatorData)
    73     { 
    74 {
    74     RPointerArray<CCsClientConversation> *clientConversationList = 
    75     RPointerArray<CCsClientConversation> *clientConversationList = new RPointerArray<
    75                                     new RPointerArray<CCsClientConversation> ();
    76         CCsClientConversation> ();
    76     CleanupStack::PushL(clientConversationList);   
    77     CleanupStack::PushL(clientConversationList);
    77     mCvServer->GetConversationUnreadListL(clientConversationList);
    78     mCvServer->GetConversationUnreadListL(clientConversationList);
    78     CleanupStack::Pop();
    79     CleanupStack::Pop();
       
    80 
       
    81     QStringList nameList;    
       
    82     int count = clientConversationList->Count();
    79     
    83     
    80     int count = clientConversationList->Count();
    84     indicatorData.mMsgCount = 0;
    81     int msgCount = 0;
    85     
    82     if(count== 1)
    86     for (int loop = 0; loop < count; ++loop) {
    83         {    
       
    84         indicatorData.mFromSingle = true;
       
    85         
    87         
    86         CCsClientConversation* conversation =
    88         CCsClientConversation* conversation =
    87         static_cast<CCsClientConversation*> ((*clientConversationList)[0]);
    89             static_cast<CCsClientConversation*> ((*clientConversationList)[loop]);
    88         
    90         
    89         CCsConversationEntry* convEntry = conversation->GetConversationEntry();
    91         CCsConversationEntry* convEntry = conversation->GetConversationEntry();
       
    92 
       
    93         indicatorData.mMsgCount += conversation->GetUnreadMessageCount();
       
    94         indicatorData.mConversationId = static_cast<int>(conversation->GetConversationEntryId());
    90         
    95         
    91         indicatorData.mUnreadMsgCount = conversation->GetUnreadMessageCount();
    96         HBufC* description = convEntry->Description();
    92         indicatorData.mConversationId = conversation->GetConversationEntryId();
    97         if (description && (count == 1)) {
       
    98             // Only take the description from convEntry when there is one entry.
       
    99             // description will contain the name list when there are more entries.
       
   100             QString descText;
       
   101             descText = S60QConversions::s60DescToQString(*description);
       
   102             descText.replace(QChar::ParagraphSeparator, QChar::LineSeparator);
       
   103             descText.replace('\r', QChar::LineSeparator);
       
   104             indicatorData.mDescription = descText;
       
   105         }
       
   106 
       
   107         if((indicatorData.mMessageType = static_cast<int>(convEntry->GetType()))==ECsBlueTooth){
       
   108             // if we have bluetooth messages, nameList should contain the LOC_RECEVED_FILES
       
   109             // string. DisplayName/number are not needed.
       
   110             nameList.append(LOC_RECEIVED_FILES);
       
   111             indicatorData.mMessageType = ECsBlueTooth ;
       
   112             continue;
       
   113         }
       
   114         else { // non-bluetooth
       
   115             HBufC* displayName = conversation->GetDisplayName();
       
   116             HBufC* number = convEntry->Contact();
       
   117 
       
   118             if (displayName) {
       
   119                 nameList.append(S60QConversions::s60DescToQString(*displayName));
       
   120             }
       
   121             else if (number) {
       
   122                 nameList.append(S60QConversions::s60DescToQString(*number));
       
   123             }
       
   124         }
       
   125     }
       
   126 
       
   127     nameList.removeDuplicates();
       
   128     nameList.sort();
       
   129     
       
   130     if (nameList.count() > 1) {
       
   131         // more than 1 sender. Concatenate the names in the description 
    93         
   132         
    94         HBufC* firstName =conversation->GetFirstName();
       
    95         HBufC* lastName = conversation->GetLastName();    
       
    96         HBufC* number =  convEntry->Contact();
       
    97         HBufC* decription = convEntry->Description();
       
    98         
       
    99         if(firstName)
       
   100             {
       
   101             indicatorData.mFirstName = S60QConversions::s60DescToQString(*firstName);
       
   102             }
       
   103         if(lastName)
       
   104             {
       
   105             indicatorData.mLastName = S60QConversions::s60DescToQString(*lastName);
       
   106             }
       
   107         if(number)
       
   108             {
       
   109             indicatorData.mContactNum  =  S60QConversions::s60DescToQString(*number);
       
   110             }
       
   111         if(decription)
       
   112             {
       
   113             indicatorData.mDescription  = S60QConversions::s60DescToQString(*decription);
       
   114             }
       
   115         
       
   116         }
       
   117     else
       
   118         {
       
   119         indicatorData.mFromSingle = false;
   133         indicatorData.mFromSingle = false;
   120         for (int loop = 0; loop < count; ++loop)
   134         indicatorData.mDescription = nameList.join(QString(", "));
   121             {
   135         indicatorData.mMessageType = ECsSMS;
   122             CCsClientConversation* conversation =
   136     }
   123             static_cast<CCsClientConversation*> ((*clientConversationList)[loop]);
   137     else{
   124             msgCount += conversation->GetUnreadMessageCount();
   138         // only 1 sender.
   125             }
   139         // displayname will have the name of the sender.
   126         indicatorData.mUnreadMsgCount = msgCount;
   140         // description will contain latest message if more than 1 message
   127         }
   141         indicatorData.mFromSingle = true;    
   128     
   142         indicatorData.mDisplayName.append(nameList.at(0));
   129     // Clean & destroy clientConversationList
       
   130        clientConversationList->ResetAndDestroy();
       
   131        delete clientConversationList;
       
   132     }
   143     }
   133     
   144     
       
   145     clientConversationList->ResetAndDestroy();
       
   146     delete clientConversationList;
       
   147 }
   134 
   148 
   135 
       
   136