idlefw/tsrc/sapidataplugin/common/observer.cpp
branchRCL_3
changeset 111 053c6c7c14f3
equal deleted inserted replaced
110:2c7f27287390 111:053c6c7c14f3
       
     1 /*
       
     2 * Copyright (c) 2010 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 // Class header
       
    19 #include "observer.h"
       
    20 
       
    21 // External includes
       
    22 #include <coemain.h>
       
    23 #include <f32file.h>
       
    24 #include <gulicon.h>
       
    25 #include <aicontentmodel.h>
       
    26 
       
    27 const char KAiShortcutCaption[] = "ShortcutCaption";
       
    28 const char KAiShortcutIcon[] = "ShortcutIcon";
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 //---------------------------------------------------------------------------
       
    33 // Observer::Observer()
       
    34 //---------------------------------------------------------------------------
       
    35 //
       
    36 Observer::Observer()
       
    37     {
       
    38     }
       
    39 
       
    40 //---------------------------------------------------------------------------
       
    41 // void Observer::ConstructL()
       
    42 //---------------------------------------------------------------------------
       
    43 //
       
    44 void Observer::ConstructL()
       
    45     {
       
    46     }
       
    47 
       
    48 //---------------------------------------------------------------------------
       
    49 // Observer* Observer::NewL()
       
    50 //---------------------------------------------------------------------------
       
    51 //
       
    52 Observer* Observer::NewL()
       
    53     {
       
    54     Observer* self = new( ELeave ) Observer();
       
    55     CleanupStack::PushL( self );
       
    56     self->ConstructL();
       
    57     CleanupStack::Pop( self );
       
    58     return self;
       
    59     }
       
    60 
       
    61 //---------------------------------------------------------------------------
       
    62 // Observer::~Observer()
       
    63 //---------------------------------------------------------------------------
       
    64 //
       
    65 Observer::~Observer()
       
    66     {
       
    67     }
       
    68 
       
    69 //---------------------------------------------------------------------------
       
    70 // TInt Observer::StartTransaction()
       
    71 //---------------------------------------------------------------------------
       
    72 //
       
    73 TInt Observer::StartTransaction( TInt aTxId )
       
    74     {
       
    75     if ( iTransactionId != 0 )
       
    76         {
       
    77         //TODO: report error
       
    78         }
       
    79     iTransactionId = aTxId;
       
    80     return KErrNone;
       
    81     }
       
    82 
       
    83 
       
    84 //---------------------------------------------------------------------------
       
    85 // TInt Observer::Commit()
       
    86 //---------------------------------------------------------------------------
       
    87 //
       
    88 TInt Observer::Commit( TInt aTxId )
       
    89     {
       
    90     TRAPD( err, DoCommitL( aTxId ) );
       
    91     return err;
       
    92     }
       
    93 
       
    94 //---------------------------------------------------------------------------
       
    95 // TInt Observer::Rollback()
       
    96 //---------------------------------------------------------------------------
       
    97 //
       
    98 TInt Observer::Rollback( TInt aTxId )
       
    99     {
       
   100     if ( iTransactionId == 0 )
       
   101         {
       
   102         //TODO: report error
       
   103         }
       
   104     else if ( iTransactionId != aTxId )
       
   105         {
       
   106         //TODO: report error
       
   107         }
       
   108     return KErrNone;
       
   109     }
       
   110 
       
   111 //---------------------------------------------------------------------------
       
   112 // TBool Observer::CanPublish()
       
   113 //---------------------------------------------------------------------------
       
   114 //
       
   115 TBool Observer::CanPublish( CHsContentPublisher& /*aPlugin*/, 
       
   116     TInt /*aContent*/, TInt /*aIndex*/ )
       
   117     {
       
   118     return ETrue;
       
   119     }
       
   120 
       
   121 //---------------------------------------------------------------------------
       
   122 // TInt Observer::Publish()
       
   123 //---------------------------------------------------------------------------
       
   124 //
       
   125 TInt Observer::Publish( CHsContentPublisher& /*aPlugin*/, 
       
   126     TInt /*aContent*/, TInt /*aResource*/, TInt /*aIndex*/ )
       
   127     {
       
   128     //TRAPD( err, DoPublishL( aPlugin, aContent, aResource, aIndex ) );
       
   129     TInt err( KErrNone );
       
   130     return err;
       
   131     }
       
   132 
       
   133 
       
   134 //---------------------------------------------------------------------------
       
   135 // TInt Observer::Publish()
       
   136 //---------------------------------------------------------------------------
       
   137 //
       
   138 TInt Observer::Publish( CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, 
       
   139     const TDesC16& /*aText*/, TInt /*aIndex*/ )
       
   140     {
       
   141     //TRAPD( err, DoPublishL( aPlugin, aContent, aText, aIndex ) );
       
   142     TInt err( KErrNone );
       
   143     return err;
       
   144     }
       
   145 
       
   146 
       
   147 //---------------------------------------------------------------------------
       
   148 // TInt Observer::Publish()
       
   149 //---------------------------------------------------------------------------
       
   150 //
       
   151 TInt Observer::Publish( CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, 
       
   152     const TDesC8& aBuf, TInt /*aIndex*/ )
       
   153     {
       
   154     CGulIcon* icon = UnpackPtr<CGulIcon>( aBuf );
       
   155     if (icon != NULL)
       
   156         {
       
   157         delete icon;
       
   158         }
       
   159     else
       
   160         {
       
   161         //TODO report error
       
   162         }
       
   163     return KErrNone;
       
   164     }
       
   165 
       
   166 //---------------------------------------------------------------------------
       
   167 // TInt Observer::Publish()
       
   168 //---------------------------------------------------------------------------
       
   169 //
       
   170 TInt Observer::Publish( CHsContentPublisher& /*aPlugin*/, 
       
   171     TInt /*aContent*/, RFile& /*aFile*/, TInt /*aIndex*/ )
       
   172     {
       
   173     return KErrNotSupported;
       
   174     }
       
   175 
       
   176 //---------------------------------------------------------------------------
       
   177 // TInt Observer::Clean()
       
   178 //---------------------------------------------------------------------------
       
   179 //
       
   180 TInt Observer::Clean( CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, 
       
   181     TInt /*aIndex*/ )
       
   182     {
       
   183     // TODO: clean content.
       
   184     iTransactionId = 0;
       
   185     return 0;
       
   186     }
       
   187 
       
   188 //---------------------------------------------------------------------------
       
   189 // TAny* Observer::Extension()
       
   190 //---------------------------------------------------------------------------
       
   191 //
       
   192 TAny* Observer::Extension( TUid /*aUid*/ )
       
   193     {
       
   194     return NULL;
       
   195     }
       
   196 
       
   197 //---------------------------------------------------------------------------
       
   198 // TBool Observer::RequiresSubscription()
       
   199 //---------------------------------------------------------------------------
       
   200 //
       
   201 TBool Observer::RequiresSubscription( 
       
   202     const THsPublisherInfo& /*aPublisherInfo*/ ) const
       
   203     {
       
   204     return EFalse;
       
   205     }
       
   206 
       
   207 
       
   208 //---------------------------------------------------------------------------
       
   209 // void Observer::DoCommitL()
       
   210 //---------------------------------------------------------------------------
       
   211 //
       
   212 void Observer::DoCommitL( TInt aTxId )
       
   213     {
       
   214     if ( iTransactionId == 0 )
       
   215         {
       
   216         //TODO: report error
       
   217         }
       
   218     else if ( iTransactionId != aTxId )
       
   219         {
       
   220         //TODO: report error
       
   221         }
       
   222     iTransactionId = 0;
       
   223     }
       
   224 
       
   225 //---------------------------------------------------------------------------
       
   226 // TInt Observer::SetProperty()
       
   227 //---------------------------------------------------------------------------
       
   228 //
       
   229 TInt Observer::SetProperty( CHsContentPublisher& /*aPlugin*/,
       
   230     const TDesC8& /*aElementId*/, const TDesC8& /*aPropertyName*/,
       
   231     const TDesC8& /*aPropertyValue*/ )
       
   232     {
       
   233 	return KErrNone;
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // TInt Observer::SetProperty()
       
   238 // ---------------------------------------------------------------------------
       
   239 //
       
   240 TInt Observer::SetProperty( CHsContentPublisher& /*aPlugin*/,
       
   241     const TDesC8& /*aElementId*/, const TDesC8& /*aPropertyName*/,
       
   242     const TDesC8& /*aPropertyValue*/, 
       
   243     MAiContentObserver::TValueType /*aValueType*/ )
       
   244     {
       
   245 	return KErrNone;
       
   246     }							                                   
       
   247 // End of File.