localconnectivityservice/obexserviceman/utils/src/obexutilsentryhandler.cpp
changeset 0 c3e98f10fcf4
child 20 3dcb815346df
equal deleted inserted replaced
-1:000000000000 0:c3e98f10fcf4
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Handles the global progress dialog 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <msvstore.h>
       
    22 #include <mmsvattachmentmanager.h>
       
    23 
       
    24 #include "obexutilsentryhandler.h"
       
    25 #include "obexutilsdebug.h"
       
    26 
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CObexutilsEntryhandler()
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CObexutilsEntryhandler::CObexutilsEntryhandler(): CActive ( EPriorityNormal )
       
    35     {
       
    36     CActiveScheduler::Add(this);
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // ConstructL()
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 void CObexutilsEntryhandler::ConstructL()
       
    44     {
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // NewL()
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CObexutilsEntryhandler* CObexutilsEntryhandler::NewL()
       
    52     {
       
    53     CObexutilsEntryhandler* self = CObexutilsEntryhandler::NewLC();
       
    54     CleanupStack::Pop( self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // NewLC()
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CObexutilsEntryhandler* CObexutilsEntryhandler::NewLC()
       
    64     {
       
    65     CObexutilsEntryhandler* self = new( ELeave ) CObexutilsEntryhandler();
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     return self;
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // AddLinkAttachment()
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 TInt CObexutilsEntryhandler::AddEntryAttachment(
       
    76     const TDesC &aFilePath, 
       
    77     CMsvAttachment* anAttachInfo, 
       
    78     CMsvStore* aStore)
       
    79     {
       
    80     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::AddEntryAttachment()"));       
       
    81     
       
    82     iStatus = KRequestPending;
       
    83   
       
    84     TRAPD(error, DoAddEntryAttachmentL(aFilePath, anAttachInfo, aStore));
       
    85     if (error != KErrNone )
       
    86         {        
       
    87         //Complete request
       
    88         TRequestStatus* status = &iStatus;
       
    89         User::RequestComplete(status, error);
       
    90         }
       
    91     
       
    92     SetActive();
       
    93     iSyncWaiter.Start();
       
    94     
       
    95     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::AddEntryAttachment() Done"));
       
    96     return iStatus.Int();
       
    97     }
       
    98 
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // DoAddLinkAttachmentL()
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 void CObexutilsEntryhandler::DoAddEntryAttachmentL(
       
   105     const TDesC &aFilePath, 
       
   106     CMsvAttachment* anAttachInfo, 
       
   107     CMsvStore* aStore)
       
   108     {
       
   109     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::DoAddEntryAttachmentL()"));   
       
   110         
       
   111     aStore->AttachmentManagerL().AddLinkedAttachmentL(aFilePath,anAttachInfo, iStatus);
       
   112     
       
   113     //Complete request
       
   114     TRequestStatus* status = &iStatus;
       
   115     User::RequestComplete(status, KErrNone);
       
   116         
       
   117     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::DoAddEntryAttachmentL() completed"));  
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // UpdateLinkAttachment()
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 TInt CObexutilsEntryhandler::UpdateEntryAttachment(
       
   125     TFileName& aFileName,
       
   126     CMsvAttachment* anOldAttachInfo,
       
   127     CMsvAttachment* aNewAttachInfo,
       
   128     CMsvStore* aStore)
       
   129     {
       
   130     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::UpdateEntryAttachment()"));       
       
   131     
       
   132     iStatus = KRequestPending;
       
   133   
       
   134     TRAPD(error, DoUpdateEntryAttachmentL(aFileName,anOldAttachInfo, aNewAttachInfo, aStore));
       
   135     if (error != KErrNone )
       
   136         {        
       
   137         //Complete request
       
   138         TRequestStatus* status = &iStatus;
       
   139         User::RequestComplete(status, error);
       
   140         }
       
   141        
       
   142     SetActive();
       
   143     iSyncWaiter.Start();
       
   144           
       
   145     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::UpdateEntryAttachment() Done"));
       
   146     return iStatus.Int();
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // DoUpdateEntryAttachmentL()
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 void CObexutilsEntryhandler::DoUpdateEntryAttachmentL(
       
   154     TFileName& aFileName,
       
   155     CMsvAttachment* anOldAttachInfo,
       
   156     CMsvAttachment* aNewAttachInfo,
       
   157     CMsvStore* aStore)
       
   158     {
       
   159     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::DoUpdateEntryAttachmentL()"));   
       
   160     aStore->AttachmentManagerL().RemoveAttachmentL(anOldAttachInfo->Id(), iStatus);
       
   161     aStore->AttachmentManagerL().AddLinkedAttachmentL(aFileName,aNewAttachInfo, iStatus);
       
   162    
       
   163     //Complete request
       
   164     TRequestStatus* status = &iStatus;
       
   165     User::RequestComplete(status, KErrNone);
       
   166         
       
   167     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::DoUpdateEntryAttachmentL() completed"));  
       
   168     }
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 // From class CActive.
       
   172 // RunL()
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 void CObexutilsEntryhandler::RunL()
       
   176     {
       
   177     if ( iSyncWaiter.IsStarted() )
       
   178         {
       
   179         iSyncWaiter.AsyncStop();
       
   180         }
       
   181     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::RunL() Done"));           
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // ~CObexutilslinkhandler()
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 CObexutilsEntryhandler::~CObexutilsEntryhandler()
       
   189     {
       
   190     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::Destructor"));     
       
   191     Cancel();    
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // From class CActive.
       
   196 // DoCancel()
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 void CObexutilsEntryhandler::DoCancel()
       
   200     {
       
   201     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::DoCancel()"));           
       
   202     if ( iSyncWaiter.IsStarted() )
       
   203         {
       
   204         iSyncWaiter.AsyncStop();
       
   205         }
       
   206     FLOG(_L("[OBEXUTILS]\t CObexutilsEntryhandler::DoCancel() done"));               
       
   207     }