uiservicetab/vimpstcmdprocess/src/cvimpstprocessfriendrequestitem.cpp
branchRCL_3
changeset 22 3104fc151679
parent 21 2b7283837edb
child 23 9a48e301e94b
equal deleted inserted replaced
21:2b7283837edb 22:3104fc151679
     1 /*
       
     2 * Copyright (c) 2008 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 for CVIMPSTProcessFriendRequestItem
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cvimpstprocessfriendrequestitem.h"
       
    19 #include "vimpstutils.h"
       
    20 #include <vimpstuires.rsg>
       
    21 #include <StringLoader.h>
       
    22 #include "tvimpstconsts.h"
       
    23 
       
    24 
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CVIMPSTProcessFriendRequestItem::default constructor
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CVIMPSTProcessFriendRequestItem::CVIMPSTProcessFriendRequestItem(CVIMPSTProcessArray& aParent):
       
    31     iParent(aParent)
       
    32     {
       
    33     
       
    34     }
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CVIMPSTProcessFriendRequestItem::NewL
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CVIMPSTProcessFriendRequestItem* CVIMPSTProcessFriendRequestItem::NewL(CVIMPSTProcessArray& aParent, const TDesC& aRequesterId,
       
    41                                                                         const TDesC& aRequestorDisplayName)
       
    42     {
       
    43     CVIMPSTProcessFriendRequestItem* self = new (ELeave) CVIMPSTProcessFriendRequestItem(aParent);
       
    44     CleanupStack::PushL(self);
       
    45     self->ConstructL(aRequesterId,aRequestorDisplayName);
       
    46     CleanupStack::Pop();
       
    47     return self;
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CVIMPSTProcessFriendRequestItem::ConstructL
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CVIMPSTProcessFriendRequestItem::ConstructL(const TDesC& aRequesterId, const TDesC& aRequestorDisplayName)
       
    55     {
       
    56      iUesrId = aRequesterId.AllocL();
       
    57      iDisplayName = aRequestorDisplayName.AllocL();
       
    58      iIndex = -1;//default index if no index is set.
       
    59      
       
    60      TInt maxLengthOfIcons = KDefaultAvatar().Length()+  // longest A-Column icon
       
    61              (KTab().Length() * 2)+ // length of tabs between items 
       
    62              KContactOnlineIconA().Length(); // longest D-Column icon
       
    63      
       
    64      iFormattedString = HBufC::NewL( KFriendsListMaxIdentificationLength +
       
    65              KStatusMsgMaxLength +
       
    66              maxLengthOfIcons );
       
    67      
       
    68      DoFormatStringL();
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CVIMPSTProcessFriendRequestItem::destructor
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 CVIMPSTProcessFriendRequestItem::~CVIMPSTProcessFriendRequestItem()
       
    76     {
       
    77     delete iUesrId;
       
    78     delete iDisplayName;
       
    79     
       
    80     if(iFormattedString)
       
    81         delete iFormattedString;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CVIMPSTProcessFriendRequestItem::GetItemNameText
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 TPtrC CVIMPSTProcessFriendRequestItem::GetItemNameText()
       
    89     {
       
    90     if((*iDisplayName).Length())
       
    91         return iDisplayName->Des();
       
    92     else 
       
    93         return iUesrId->Des();
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CVIMPSTProcessFriendRequestItem::Type
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 TVIMPSTEnums::TItem CVIMPSTProcessFriendRequestItem::Type()
       
   101     {
       
   102     return TVIMPSTEnums::EFriendRequestItem;
       
   103     }
       
   104 
       
   105 /**
       
   106 * Returns the user id of the listbox item 
       
   107 * @return TPtrC: user id of the listbox item.
       
   108 */
       
   109 TPtrC CVIMPSTProcessFriendRequestItem::GetItemUserId()
       
   110     {
       
   111     return iUesrId->Des();
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 //CVIMPSTProcessFriendRequestItem: SetMsgPending
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CVIMPSTProcessFriendRequestItem::SetMsgPending(TBool aPendingMessageStatus)
       
   119     {
       
   120     iSMsgPending = aPendingMessageStatus;
       
   121     
       
   122     TRAP_IGNORE(DoFormatStringL());
       
   123     }
       
   124 // -----------------------------------------------------------------------------
       
   125 //CVIMPSTProcessFriendRequestItem: GetMsgPending
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 TBool CVIMPSTProcessFriendRequestItem::IsMsgPending()
       
   129     {
       
   130     return iSMsgPending;
       
   131     }
       
   132 // -----------------------------------------------------------------------------
       
   133 //CVIMPSTProcessFriendRequestItem: SetConversationOpen
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CVIMPSTProcessFriendRequestItem::SetConversationOpen(TBool aConversationOpen)
       
   137     {
       
   138     iIsConversationOpen = aConversationOpen;
       
   139     
       
   140     TRAP_IGNORE(DoFormatStringL());
       
   141     }
       
   142 // -----------------------------------------------------------------------------
       
   143 //CVIMPSTProcessFriendRequestItem: IsConversationOpen
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 TBool CVIMPSTProcessFriendRequestItem::IsConversationOpen()
       
   147     {
       
   148     return iIsConversationOpen;
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CVIMPSTProcessFriendRequestItem::FormattedItemString
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 TPtrC16 CVIMPSTProcessFriendRequestItem::FormattedItemString()
       
   156     {
       
   157     if(iFormattedString)
       
   158         return iFormattedString->Des();
       
   159     else
       
   160         return KNullDesC();
       
   161     }
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CVIMPSTProcessFriendRequestItem::DoFormatString
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 void CVIMPSTProcessFriendRequestItem::DoFormatStringL()
       
   168     {
       
   169     
       
   170     TPtr dataPtr( iFormattedString->Des() );
       
   171         dataPtr.Zero();
       
   172     
       
   173     
       
   174     if ( TVIMPSTEnums::ESVCERegistered == iParent.GetLoginState())
       
   175             {
       
   176             // append friend request icon online for column A 
       
   177             dataPtr.Append( KLocalPendingRequest );
       
   178             }
       
   179         else
       
   180             {// append friend request icon offline for column A 
       
   181             dataPtr.Append( KLocalPendingRequestOffline );
       
   182             }
       
   183         
       
   184         // B-column  append friend request text
       
   185         HBufC* friendRequestText = StringLoader::LoadLC(R_SERVTAB_FRIEND_REQUEST);
       
   186         dataPtr.Append( friendRequestText->Des() );
       
   187         CleanupStack::PopAndDestroy(friendRequestText);
       
   188         
       
   189         // append  \t before second line text
       
   190         dataPtr.Append( KTab );
       
   191         // append the  user id 
       
   192         dataPtr.Append(GetItemNameText().Left( KFriendsListMaxIdentificationLength ));    
       
   193     
       
   194     }