webservices/wsmessages/inc/senatommessage.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2009 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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef CSENATOMMESSAGE_H_
       
    24 #define CSENATOMMESSAGE_H_
       
    25 
       
    26 //  INCLUDES
       
    27 #include <e32base.h>
       
    28 #include <e32cmn.h>
       
    29 
       
    30 #include <SenDomFragmentBase.h>
       
    31 #include <MSenMessage.h>
       
    32 
       
    33 // CONSTANTS
       
    34 _LIT8(KSenAtomEntryXmlns,                 "http://www.w3.org/2005/Atom");
       
    35 _LIT8(KSenAtomFeedName,                   "feed");
       
    36 _LIT8(KSenAtomEntryName,                  "entry");
       
    37 
       
    38 _LIT8(KSenAtomCategoryName,               "category");
       
    39 _LIT8(KSenAtomGroupName,                  "group");
       
    40 _LIT8(KSenAtomTitleName,                     "title");
       
    41 _LIT8(KSenAtomUpdatedName,                "updated");
       
    42 _LIT8(KSenAtomPublishedName,                "published");
       
    43 _LIT8(KSenAtomIdName,                    "id");
       
    44 _LIT8(KSenAtomLinkName,                    "link");
       
    45 _LIT8(KSenAtomSubtitleName,                "subtitle");
       
    46 _LIT8(KSenAtomGeneratorName,                "generator");
       
    47 _LIT8(KSenAtomIconName,                      "icon");
       
    48 _LIT8(KSenAtomLogoName,                      "logo");
       
    49 _LIT8(KSenAtomRightsName,                 "rights");
       
    50 _LIT8(KSenAtomContributorName,           "contributor");
       
    51 _LIT8(KSenAtomContentName,                "content");
       
    52 _LIT8(KSenAtomAuthorName,                "author");
       
    53 
       
    54 _LIT8(KSenAtomName,                         "name"); 
       
    55 _LIT8(KSenAtomURI,                          "URI");
       
    56 _LIT8(KSenAtomEmail,                      "email");
       
    57 _LIT8(KSenAtomVersion,                      "version");
       
    58 _LIT8(KSenAtomHref,                        "href");
       
    59 _LIT8(KSenAtomRel,                        "rel");
       
    60 _LIT8(KSenAtomType,                        "type");
       
    61 _LIT8(KSenAtomHrefLang,                     "hrefLang");
       
    62 _LIT8(KSenAtomTitle,                        "title");
       
    63 _LIT8(KSenAtomLength,                       "length");
       
    64 _LIT8(KSenAtomPrefix,                        " ");
       
    65 _LIT8(KSenAtomTerm,                        "term");
       
    66 _LIT8(KSenAtomScheme,                        "scheme");
       
    67 _LIT8(KSenAtomLabel,                        "label");
       
    68 
       
    69 _LIT8(KSenAtomSpace,                      "");
       
    70 
       
    71 
       
    72 
       
    73 /// id for data class instances
       
    74 typedef TInt64 TAtomDataId;
       
    75 
       
    76 // FORWARD DECLARATIONS
       
    77 
       
    78 // CLASS DECLARATION
       
    79 /**
       
    80 *     Provides generic object to keep and manipulate tags of atom-pub API.
       
    81 * 
       
    82 *   @lib SenMessages.DLL
       
    83 *   @since 5.0
       
    84 */
       
    85 
       
    86 class CSenAtomMessage : public CSenFragmentBase, public MSenMessage
       
    87     {
       
    88     public:  // Constructors and destructor
       
    89                       
       
    90         /**
       
    91         * Destructor.
       
    92         */
       
    93         IMPORT_C virtual ~CSenAtomMessage();   
       
    94         
       
    95     public:
       
    96         IMPORT_C TAtomDataId Id() const;
       
    97         
       
    98     public: // From MSenMessage
       
    99         IMPORT_C virtual TClass Type();
       
   100         IMPORT_C virtual TDirection Direction();
       
   101         IMPORT_C virtual TInt SetContext(MSenMessageContext* apOwnedContext);
       
   102         IMPORT_C virtual MSenMessageContext* Context();
       
   103         IMPORT_C virtual TInt SetProperties(MSenProperties* apOwnedProperties);
       
   104         IMPORT_C virtual MSenProperties* Properties();
       
   105         IMPORT_C virtual TBool IsSafeToCast(TClass aType);
       
   106         IMPORT_C virtual TInt TxnId();
       
   107         IMPORT_C virtual MSenMessage* CloneL();
       
   108         
       
   109         // From CSenFragmentBase
       
   110         IMPORT_C virtual void OnStartElementL(const RTagInfo& aElement,
       
   111                                               const RAttributeArray& aAttributes,
       
   112                                               TInt aErrorCode);                                            
       
   113 
       
   114         IMPORT_C virtual void OnEndElementL(const RTagInfo& aElement,
       
   115                                             TInt aErrorCode);
       
   116         IMPORT_C virtual CSenFragmentBase* CreateBodyFragmentL(const TDesC8& aNsUri,
       
   117                                                        const TDesC8& aLocalName,
       
   118                                                        const TDesC8& aPrefix,
       
   119                                                        const RAttributeArray& aAttributes,
       
   120                                                        TXmlEngElement& aParent,
       
   121                                                        RSenDocument& aOwnerDocument);
       
   122         
       
   123         // Own functions
       
   124         
       
   125         /*
       
   126         *        Method returns content of "title" tag
       
   127         *         @return - descriptor containing value of title.
       
   128         */        
       
   129         IMPORT_C const TDesC8& Title() const;
       
   130         
       
   131         /*
       
   132         *        Method sets content of "title" tag
       
   133         *         @param aTitle - descriptor that contains value of subtitle. 
       
   134         */
       
   135         IMPORT_C void SetTitleL( const TDesC8& aTitle );
       
   136         
       
   137         /*
       
   138         *        Method returns content of "updated" tag
       
   139         *         @return - descriptor containing value of updated tag.
       
   140         */        
       
   141         IMPORT_C const TDesC8& Updated() const;
       
   142         
       
   143         /*
       
   144         *        Method sets content of "updated" tag
       
   145         *         @param aUpdated - descriptor that contains value of updated tag.
       
   146         */        
       
   147         IMPORT_C void SetUpdatedL( const TDesC8& aUpdated );
       
   148         
       
   149         /*
       
   150         *        Method returns content of "published" tag
       
   151         *         @return - descriptor containing value of published tag.
       
   152         */        
       
   153         IMPORT_C const TDesC8& Published() const;
       
   154         
       
   155         /*
       
   156         *        Method sets content of "published" tag
       
   157         *         @param aPublished - descriptor that contains value of published tag.
       
   158         */        
       
   159         IMPORT_C void SetPublishedL( const TDesC8& aPublished );
       
   160         
       
   161         /*
       
   162         *        Method returns content of "id" tag. Content of this tag usually identifies underlying entry or feed. 
       
   163         *         @return - descriptor containing value of id tag.
       
   164         */        
       
   165         IMPORT_C const TDesC8& IdTag() const;
       
   166         
       
   167         /*
       
   168         *        Method sets content of "id" tag. Content of this tag usually identifies underlying entry or feed.
       
   169         *         @param aId - descriptor that contains value of 'id' tag.
       
   170         */        
       
   171         IMPORT_C void SetIdTagL( const TDesC8& aId );
       
   172         
       
   173         /*
       
   174         *        Adds a "link" tag to the message. Parameters describe subtags with a corresponding name.
       
   175         *         In case of subtag's value of KNullDesC8, it is ommited. Allows adding multiple links.
       
   176         *         @param aHref - set the content of 'href' attribute
       
   177         *         @param aRel - set the content of 'rel' attribute 
       
   178         *         @param aType - set the content of 'type' attribute 
       
   179         *         @param aHreflang - set the content of 'hrefLang' attribute
       
   180         *         @param aTitle - set the content of 'title' attribute
       
   181         *         @param aLenght - set the content of 'length' attribute
       
   182         * 
       
   183         */
       
   184         IMPORT_C void AddLinkL( const TDesC8& aHref, const TDesC8& aRel, const TDesC8& aType, const TDesC8& aHreflang, const TDesC8& aTitle, const TDesC8& aLength);
       
   185         
       
   186         /*
       
   187         *        Removes "link" tag. 
       
   188         *       @param aLenght - it's an order of a link in an xml document(or element) containing atom message. 
       
   189         */
       
   190         IMPORT_C void RemoveLinkL( TInt aIndex);
       
   191         
       
   192         /*
       
   193         *        Removes first "link" tag from the message with a "href" described with @href parameter (href is a must be in a link)
       
   194         *         @param aHref - href of a link to delete.
       
   195         */
       
   196         IMPORT_C void RemoveLinkL(const TDesC8& aHref);
       
   197         
       
   198         /*
       
   199         *        Returns a total count of "link" tags in the message.
       
   200         *         @return - count of links
       
   201         */
       
   202         IMPORT_C TInt LinkCountL();
       
   203         
       
   204         /*
       
   205         *        Returns a total count of "category" tags in the entry.
       
   206         *         @return - count of category
       
   207         */
       
   208         IMPORT_C TInt CategoryCountL();
       
   209         
       
   210         /*
       
   211         *        Method adds a "category" tag to the entry. Parameters describe subtags with a corresponding name. If param is KNullDesC8
       
   212         *         it is ommited.
       
   213         *         @param aTerm - content of  'term' tag
       
   214         *         @param aScheme - content of  'scheme' tag
       
   215         *         @param aLabel- content of  'label' tag
       
   216         */
       
   217         IMPORT_C void AddCategoryL( const TDesC8& aTerm, const TDesC8& aScheme, const TDesC8& aLabel);
       
   218         
       
   219         /*
       
   220         *        Removes first "category" tag from the entry with a "term" described with @term parameter.
       
   221         *         @param aTerm - value of 'term' tag of category to remove
       
   222         */
       
   223         IMPORT_C void RemoveCategoryL(const TDesC8& aTerm);   
       
   224         
       
   225         /*
       
   226         *        Removes all "author" tags from the entry, as there is only one author tag allowed, 
       
   227         */
       
   228         IMPORT_C void RemoveAuthorL();
       
   229         
       
   230         /*
       
   231         *        Sets "author" tag to the entry. Parameters describe subtags with a corresponding name.
       
   232         *         In case of subtag's value of KNullDesC8, it is ommited. Allows adding multiple authors.
       
   233         *         @param aName - author's name 
       
   234         *         @param aUri - author's uri 
       
   235         *         @param aEmail - author's email 
       
   236         */        
       
   237         IMPORT_C void SetAuthorL( const TDesC8& aName, const TDesC8& aUri, const TDesC8& aEmail);
       
   238         
       
   239         /*
       
   240         *        Removes first "contributor" tag from the entry with 'name' specified by @name .
       
   241         *         @param aName - name of a contributor to remove 
       
   242         */
       
   243         IMPORT_C void RemoveContributorL( const TDesC8& aName);
       
   244         
       
   245         /*
       
   246         *        Adds "contributor" tag to the entry. Parameters describe subtags with a corresponding name.
       
   247         *         In case of subtag's value of KNullDesC8, it is ommited. 
       
   248         *        @param aName - contributor's name 
       
   249         *         @param aUri - contributor's uri 
       
   250         *         @param aEmail - - contributor's email 
       
   251         */
       
   252         IMPORT_C void AddContributorL( const TDesC8& aName, const TDesC8& aUri, const TDesC8& aEmail);
       
   253         
       
   254         /*
       
   255         *        Returns a total count of "contributor" tags in the entry.
       
   256         *         @return - count of contributor's
       
   257         */
       
   258         IMPORT_C TInt ContributorCountL();
       
   259         
       
   260         /*
       
   261         *        @return content of the "righst" tag.
       
   262         */
       
   263         IMPORT_C const TDesC8& RightsL();
       
   264         
       
   265         /*
       
   266         *        Method sets content of "rights" tag
       
   267         *         @param aRights - value of a "rights" tag
       
   268         */
       
   269         IMPORT_C void SetRightsL( const TDesC8& aRights);
       
   270         
       
   271         /*
       
   272         *        This method return count of any tag with a name specified by @name and namespace specified by @nameSpaceURI
       
   273         *         @param aName - value of a "name" tag
       
   274         *         @param aNameSpaceURI - value of a "NameSpaceURI" tag
       
   275         */
       
   276         IMPORT_C TInt AttributeCountL(const TDesC8& aName, const TDesC8& aNameSpaceURI);
       
   277         
       
   278         /*
       
   279         *        This method allows any tag removal. It removes first tag within the entry with parameters specified. 
       
   280         *         Paramteres are:
       
   281         *             @aAtomtag - name of tag to remove
       
   282         *             @aNameSpaceUri - tag to remove namespace
       
   283         *             @aAttributeName - name attribute specifing a tag
       
   284         *             @aValue - value of attribute specifing a tag
       
   285         *     for example:
       
   286         *         removes a tag 
       
   287         *        <atomtag xmlns=nameSpaceURI attributeName=value>  ... </atomtag>     
       
   288         */
       
   289         IMPORT_C void RemoveByAttributeL(const TDesC8& aAtomtag, const TDesC8& aNameSpaceUri, const TDesC8& aAttributeName, const TDesC8& aValue);
       
   290         
       
   291         /*
       
   292         *        This method allows any tag removal. It removes first tag within the entry with parameters specified. 
       
   293         *         Paramteres are:
       
   294         *             @aAtomtag - name of tag to remove
       
   295         *             @aNameSpaceUri - tag to remove namespace
       
   296         *             @aSubTagName - name attribute specifing a tag
       
   297         *             @aValue - value of attribute specifing a tag
       
   298         *     for example:
       
   299         *         removes a tag 
       
   300         *        
       
   301         *         <atomtag xmlns=nameSpaceURI>
       
   302         *                 ..
       
   303         *                 <subtagName>value</subtagName>
       
   304         *          </atomtag>     
       
   305         */
       
   306         IMPORT_C void RemoveBySubtagL(const TDesC8& aAtomtag, const TDesC8& aNameSpaceUri, const TDesC8& aSubTagName, const TDesC8& aValue);
       
   307         
       
   308 
       
   309     protected:
       
   310 
       
   311         /**
       
   312          *  Constructor.
       
   313          */
       
   314         CSenAtomMessage();
       
   315         
       
   316     protected: // Data
       
   317         TInt64 iId;
       
   318         
       
   319         // part of content information is contained as hbufs
       
   320         HBufC8* iTitle;
       
   321         HBufC8* iIdTag;
       
   322         HBufC8* iUpdated;
       
   323         HBufC8* iPublished;
       
   324     
       
   325     };
       
   326 
       
   327 #endif /*CSENATOMMESSAGE_H_*/