utilities/downloadmanager/inc/omaddparser.h
changeset 16 3c88a81ff781
equal deleted inserted replaced
14:6aeb7a756187 16:3c88a81ff781
       
     1 /**
       
     2    This file is part of CWRT package **
       
     3 
       
     4    Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). **
       
     5 
       
     6    This program is free software: you can redistribute it and/or modify
       
     7    it under the terms of the GNU (Lesser) General Public License as 
       
     8    published by the Free Software Foundation, version 2.1 of the License. 
       
     9    This program is distributed in the hope that it will be useful, but
       
    10    WITHOUT ANY WARRANTY; without even the implied warranty of 
       
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
       
    12    (Lesser) General Public License for more details. You should have 
       
    13    received a copy of the GNU (Lesser) General Public License along 
       
    14    with this program. If not, see <http://www.gnu.org/licenses/>.
       
    15 */
       
    16 
       
    17 #ifndef OMADDPARSER_H_
       
    18 #define OMADDPARSER_H_
       
    19 
       
    20 #include "dmcommon.h"
       
    21 #include "dmcommoninternal.h"
       
    22 #include "dmpimpl.h"
       
    23 #include <QtXml>
       
    24 #include <QVariant>
       
    25 #include <QStack>
       
    26 
       
    27 // forward declarations
       
    28 class QString;
       
    29 class OMADownloadDescriptor;
       
    30 class OMADownloadDescParserPrivate;
       
    31 class OMADownloadDescriptorPrivate;
       
    32 class OMA2DownloadProduct;
       
    33 class OMA2DownloadProductPrivate;
       
    34 class OMA2DownloadMediaObj;
       
    35 class OMA2DownloadMediaObjPrivate;
       
    36 
       
    37 typedef QList<OMA2DownloadProduct*> ProductList;
       
    38 typedef QList<OMA2DownloadMediaObj*> MediaObjectList;
       
    39 
       
    40 enum OMADownloadAttribute
       
    41 {
       
    42     /* OMA Download Attributes */
       
    43     OMADownloadDescName = 0,                  // "name" in OMA dd
       
    44     OMADownloadDescVersion,                   // "version" in OMA dd
       
    45     OMADownloadDescObjectURI,                 // "objectURI" in OMA dd
       
    46     OMADownloadDescType,                      // "type" in OMA dd
       
    47     OMADownloadDescSize,                      // "size" in OMA dd
       
    48     OMADownloadDescVendor,                    // "vendor" in OMA dd
       
    49     OMADownloadDescDescription,               // "description" in OMA dd
       
    50     OMADownloadDescInstallNotifyURI,          // "installNotifyURI" in OMA dd
       
    51     OMADownloadDescNextURL,                   // "nextURL" in OMA dd
       
    52     OMADownloadDescInfoURL,                   // "infoURL" in OMA dd
       
    53     OMADownloadDescIconURL,                   // "iconURL" in OMA dd
       
    54     OMADownloadDescInstallParam,              // "instalParam" in OMA dd
       
    55 
       
    56     /* OMA2 Download Attributes */
       
    57     OMA2DownloadDescUpdatedDDURI,             // "updatedDDURI" in OMA dd2
       
    58     OMA2DownloadDescProductName,              // "product" in OMA dd2
       
    59     OMA2DownloadDescProductInstallNotifyURI,  // "installNotifyURI" of product in OMA dd2
       
    60     OMA2DownloadDescProductSuppressConfirmation,  // "suppressuserconfirmation" of product in OMA dd2
       
    61     OMA2DownloadDescMediaObjName,             // "mediaObject" in OMA dd2
       
    62     OMA2DownloadDescMediaObjType,             // "type" in OMA dd2
       
    63     OMA2DownloadDescMediaObjSize,             // "size" in OMA dd2
       
    64     OMA2DownloadDescMediaObjProgressiveDl,    // "progressivedl" in OMA dd2
       
    65     OMA2DownloadDescMediaObjServer,           // "server" in OMA dd2
       
    66     OMA2DownloadDescMediaObjInstallNotifyURI, // "installNotifyURI" of mediaObj in OMA dd2
       
    67     OMA2DownloadDescMediaObjSuppressConfirmation, // "suppressuserconfirmation" of mediaobj in OMA dd2
       
    68     OMA2DownloadDescLicense,                  // "license" in OMA dd2
       
    69     OMA2DownloadDescOrder,                    // "order" in OMA dd2
       
    70     OMA2DownloadDescText                      // "text" in OMA dd2 
       
    71 };
       
    72 // class declaration
       
    73 
       
    74 // for parsing the OMA download descriptor
       
    75 class  OMADownloadDescParser : public QXmlDefaultHandler
       
    76 {
       
    77     DM_DECLARE_PRIVATE(OMADownloadDescParser);
       
    78 
       
    79 public:
       
    80     OMADownloadDescParser();
       
    81     ~OMADownloadDescParser();
       
    82     bool startDocument();
       
    83     bool startElement(const QString&, const QString&, const QString& ,
       
    84                        const QXmlAttributes&);
       
    85     bool endElement(const QString&, const QString&, const QString&);
       
    86     bool characters(const QString& ch);
       
    87     QString errorString();
       
    88     bool fatalError(const QXmlParseException &exception);
       
    89     OMADownloadDescriptor* downloadDescriptor();
       
    90 };
       
    91 
       
    92 // represents OMA download descriptor
       
    93 class OMADownloadDescriptor
       
    94 {
       
    95     DM_DECLARE_PRIVATE(OMADownloadDescriptor);
       
    96 public:
       
    97     OMADownloadDescriptor();
       
    98     ~OMADownloadDescriptor();
       
    99     // fetches the OMA DD related attributes
       
   100     QVariant getAttribute(OMADownloadAttribute attr);
       
   101     // sets the attributes if any
       
   102     void setAttribute(const QString&, const QVariant&);
       
   103     // fetches the product List
       
   104     QList<OMA2DownloadProduct*> productList();
       
   105     // fetches the product count in a dd
       
   106     int productCount();
       
   107     // adding product to the list
       
   108     void addProduct(OMA2DownloadProduct*);
       
   109 };
       
   110 
       
   111 class OMA2DownloadProduct
       
   112 {
       
   113     DM_DECLARE_PRIVATE(OMA2DownloadProduct);
       
   114 public:
       
   115     OMA2DownloadProduct();
       
   116     ~OMA2DownloadProduct();
       
   117     // fetches Product related attributes
       
   118     QVariant getAttribute(OMADownloadAttribute attr);
       
   119     // sets the Product attributes if any
       
   120     void setAttribute(const QString&, const QVariant&);
       
   121     // fetches the Media Object list
       
   122     QList<OMA2DownloadMediaObj*> mediaObjList();
       
   123     // fetches the number of media downloads in a product
       
   124     int mediaCount();
       
   125     // fetches the size of all the media objects present in dd
       
   126     qint64 albumSize();
       
   127     // adding media object to the media object list.
       
   128     void addMediaObject(OMA2DownloadMediaObj*);
       
   129 };
       
   130 
       
   131 class OMA2DownloadMediaObj
       
   132 {
       
   133     DM_DECLARE_PRIVATE(OMA2DownloadMediaObj);
       
   134 public:
       
   135     OMA2DownloadMediaObj();
       
   136     ~OMA2DownloadMediaObj();
       
   137     // fetches the Media Object attributes
       
   138     QVariant getAttribute(OMADownloadAttribute attr);
       
   139     // sets the Media Object attributes if any
       
   140     void setAttribute(const QString&, const QVariant&);
       
   141 };
       
   142 #endif