src/hbtools/docml2bin/main.cpp
changeset 5 627c4a0fd0e7
parent 2 06ff229162e9
child 7 923ff622b8b9
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
       
    26 #include <QCoreApplication>
       
    27 #include <QStringList>
       
    28 #include <QFile>
    26 #include <hbdocumentloader.h>
    29 #include <hbdocumentloader.h>
    27 #include <QtGui>
       
    28 #include <assert.h>
    30 #include <assert.h>
    29 #include <iostream>
    31 #include <iostream>
       
    32 
       
    33 #include <QDebug>
    30 
    34 
    31 
    35 
    32 void showHelp() {
    36 void showHelp() {
    33     std::cout << "docml2bin.exe usage:\n\n";
    37     std::cout << "docml2bin.exe usage:\n\n";
    34 
    38 
    48     std::cout << "docml2bin.exe -s myfile.docml -t c:/resouces/bin/mybinary.docml\n\n";
    52     std::cout << "docml2bin.exe -s myfile.docml -t c:/resouces/bin/mybinary.docml\n\n";
    49 }
    53 }
    50 
    54 
    51 int main(int argc, char *argv[])
    55 int main(int argc, char *argv[])
    52 {
    56 {
    53     QApplication app(argc, argv, false); // GUIenabled=false
    57 
       
    58     qDebug() << "docml2bin, 1";
       
    59 
       
    60     QCoreApplication app(argc, argv);
    54 
    61 
    55     if (argc <= 2) {
    62     if (argc <= 2) {
    56         showHelp();
    63         showHelp();
    57     } else {
    64     } else {
       
    65         qDebug() << "docml2bin, 2";
    58         //bool backup = false;
    66         //bool backup = false;
    59         QString source, target;
    67         QString source, target;
    60         //QStringList restore;
    68         //QStringList restore;
    61         QStringList args(app.arguments());
    69         QStringList args(app.arguments());
    62 
    70 
    77                     n++;
    85                     n++;
    78                 }
    86                 }
    79             */
    87             */
    80             }
    88             }
    81         }
    89         }
       
    90         qDebug() << "docml2bin, 3";
    82         /*
    91         /*
    83         if (restore.count()) {
    92         if (restore.count()) {
    84             for (int i = 0; i < restore.count(); i++) {
    93             for (int i = 0; i < restore.count(); i++) {
    85                 QString orig = restore.at(i) + ".orig";
    94                 QString orig = restore.at(i) + ".orig";
    86                 if ( QFile::exists(orig) ) {
    95                 if ( QFile::exists(orig) ) {
   104                 origFile.rename(orig);
   113                 origFile.rename(orig);
   105                 target = source;
   114                 target = source;
   106                 source = orig;
   115                 source = orig;
   107             }
   116             }
   108             */
   117             */
       
   118             qDebug() << "docml2bin, 4";
   109             if (!QFile::exists(source)) {
   119             if (!QFile::exists(source)) {
   110                 std::cout << "Error: file " << source.toStdString() << " does not exist.\n";
   120                 std::cout << "Error: file " << source.toStdString() << " does not exist.\n";
   111             } else {
   121             } else {
       
   122                 qDebug() << "docml2bin, 5";
   112                 // Open file and parse lines. Each line should have three value separated with:
   123                 // Open file and parse lines. Each line should have three value separated with:
   113                 QFile sourceFile(source);
   124                 QFile sourceFile(source);
   114                 if (sourceFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
   125                 if (sourceFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
       
   126                     qDebug() << "docml2bin, 6";
   115                     if (!target.length()) {
   127                     if (!target.length()) {
   116                         target = source + ".bin";
   128                         target = source + ".bin";
   117                     }
   129                     }
   118                     QFile targetFile(target);
   130                     QFile targetFile(target);
   119                     if (targetFile.open(QIODevice::WriteOnly)) {
   131                     if (targetFile.open(QIODevice::WriteOnly)) {
       
   132                         qDebug() << "docml2bin, 7";
   120                         HbDocumentLoader loader;
   133                         HbDocumentLoader loader;
   121                         loader.createBinary( &sourceFile, &targetFile );
   134                         loader.createBinary( &sourceFile, &targetFile );
       
   135                         qDebug() << "docml2bin, 8";
   122                         targetFile.close();
   136                         targetFile.close();
   123                     }
   137                     }
   124                     sourceFile.close();
   138                     sourceFile.close();
   125                 }
   139                 }
   126             }
   140             }
   127         }
   141         }
   128     }
   142     }
       
   143     qDebug() << "docml2bin, 9";
   129 
   144 
   130     return 0;
   145     return 0;
   131 }
   146 }
   132 
   147