~ubuntu-branches/ubuntu/utopic/robojournal/utopic

« back to all changes in this revision

Viewing changes to configmanager.cpp

  • Committer: Package Import Robot
  • Author(s): Ritesh Raj Sarraf
  • Date: 2013-10-22 11:50:46 UTC
  • mfrom: (1.2.1) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20131022115046-gl6s110no2x4buoc
Tags: 0.4.2-1
* [b62d8ee] Imported Upstream version 0.4.2
* [344ee28] Update patches
* [3366262] Fix Vcs Links
* Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of RoboJournal.
3
 
    Copyright (c) 2012 by Will Kraft <pwizard@gmail.com>.
4
 
 
5
 
 
6
 
    RoboJournal is free software: you can redistribute it and/or modify
7
 
    it under the terms of the GNU General Public License as published by
8
 
    the Free Software Foundation, either version 3 of the License, or
9
 
    (at your option) any later version.
10
 
 
11
 
    RoboJournal is distributed in the hope that it will be useful,
12
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
    GNU General Public License for more details.
15
 
 
16
 
    You should have received a copy of the GNU General Public License
17
 
    along with RoboJournal.  If not, see <http://www.gnu.org/licenses/>.
18
 
  */
19
 
 
20
 
 
21
 
#include "configmanager.h"
22
 
#include <config.h>
23
 
#include <ui_config.h>
24
 
#include <iostream>
25
 
#include <QDebug>
26
 
#include <QFile>
27
 
#include <QDir>
28
 
#include <stdlib.h>
29
 
#include <buffer.h>
30
 
#include <QErrorMessage>
31
 
#include <QMessageBox>
32
 
#include "newdatabase.h"
33
 
#include <QAbstractButton>
34
 
#include "firstrun.h"
35
 
#include "ui_firstrun.h"
36
 
 
37
 
 
38
 
// get user home directory
39
 
QString homedir=QDir::homePath();
40
 
QChar separator=QDir::separator();
41
 
QString configdir=".robojournal";
42
 
QDir directory;
43
 
 
44
 
// Config-specific:
45
 
QString Config::new_allow_root;
46
 
QString Config::new_entry_range;
47
 
QString Config::new_always_use_defaults;
48
 
QString Config::new_dbtype;
49
 
QString Config::new_default_db;
50
 
QString Config::new_default_host;
51
 
QString Config::new_default_port;
52
 
QString Config::new_default_user;
53
 
QString Config::new_show_all_entries;
54
 
QString Config::new_show_confirm;
55
 
QString Config::new_toolbar_pos;
56
 
QString Config::new_sort_by_day;
57
 
QString Config::new_alternate_rows;
58
 
QString Config::new_use_background;
59
 
QString Config::new_show_title;
60
 
QString Config::new_use_custom_theme;
61
 
QString Config::new_tile_bg;
62
 
QString Config::new_use_background_in_tree;
63
 
QString Config::new_text_hexcolor;
64
 
QString Config::new_font_face;
65
 
QString Config::new_background_image;
66
 
QString Config::new_font_size;
67
 
QString Config::new_record_time;
68
 
QString Config::new_use_local_time;
69
 
QString Config::new_24_hr;
70
 
QString Config::new_rich_text;
71
 
QString Config::new_date_mode;
72
 
QString Config::new_icon_labels;
73
 
 
74
 
 
75
 
//###################################################################################################
76
 
// Config home dir setup
77
 
QString configpath=homedir+separator+configdir;
78
 
 
79
 
 
80
 
// config file name
81
 
QString config_name=homedir+separator+configdir+separator+"robojournal.cfg";
82
 
QFile configfile(config_name);
83
 
 
84
 
 
85
 
ConfigManager::ConfigManager()
86
 
{
87
 
}
88
 
 
89
 
// Function that loads config data into buffer on startup
90
 
 
91
 
void ConfigManager::ReadConfig(){
92
 
    using namespace std;
93
 
    QString var;
94
 
 
95
 
    cout << "Output: Using home path: " + configpath.toStdString() << endl;
96
 
 
97
 
 
98
 
    // Check for config file when program starts. If it's not there, rebuild it.
99
 
    if(!configfile.exists()){
100
 
        cout << "ERROR: Config file not found, rebuilding..." << endl;
101
 
 
102
 
        // give the journal creator a way to know its the first run
103
 
        Buffer::firstrun=true;
104
 
 
105
 
        // Launch the firstrun tool
106
 
 
107
 
        FirstRun f;
108
 
        f.exec();
109
 
 
110
 
        // Don't use the old RebuildConfig anymore now that the FirstRun tool is ready
111
 
        //RebuildConfig();
112
 
 
113
 
 
114
 
        //cout << "Done!" << endl;
115
 
    }
116
 
 
117
 
    cout << "OUTPUT: Reading data from config file robojournal.cfg...";
118
 
 
119
 
 
120
 
    if (!configfile.open(QIODevice::ReadOnly | QIODevice::Text))
121
 
            return;
122
 
 
123
 
    int linenum=0;
124
 
 
125
 
    while(!configfile.atEnd()){
126
 
        linenum++;
127
 
        QString thisline=configfile.readLine();
128
 
       //cout << thisline.toStdString();
129
 
 
130
 
 
131
 
        if(linenum==3){
132
 
            //int * location;
133
 
            var=thisline.remove(0,17);
134
 
            int toolbar_pos=var.toInt();
135
 
            Buffer::toolbar_pos=toolbar_pos;
136
 
        }
137
 
 
138
 
        if(linenum==4){
139
 
            var=thisline.remove(0, 18);
140
 
            //cout << "Allow root: " << var.toStdString();
141
 
            if(var.trimmed()=="1"){
142
 
                Buffer::allowroot=true;
143
 
 
144
 
            }
145
 
            else{
146
 
                Buffer::allowroot=false;
147
 
 
148
 
            }
149
 
 
150
 
        }
151
 
 
152
 
        if(linenum==5){
153
 
            var=thisline.remove(0, 17);
154
 
            //cout << "Allow all entries: " << var.toStdString();
155
 
            if(var.trimmed()=="0"){
156
 
                Buffer::allentries=false;
157
 
 
158
 
            }
159
 
            else{
160
 
                Buffer::allentries=true;
161
 
 
162
 
            }
163
 
        }
164
 
 
165
 
        if(linenum==6){
166
 
            var=thisline.remove(0, 20);
167
 
            //cout << "Always use defaults: " << var.toStdString();
168
 
            if(var.trimmed()=="0"){
169
 
                Buffer::alwaysusedefaults=false;
170
 
                //cout << "defaults are false";
171
 
            }
172
 
            else{
173
 
                Buffer::alwaysusedefaults=true;
174
 
                //cout << "defaults are true";
175
 
            }
176
 
 
177
 
        }
178
 
 
179
 
        if(linenum==7){
180
 
            var=thisline.remove(0, 8);
181
 
            //cout << "Database type: " << var.toStdString();
182
 
            Buffer::backend=var.trimmed();
183
 
        }
184
 
 
185
 
        if(linenum==8){
186
 
            var=thisline.remove(0, 14);
187
 
            //cout << "Always warn: " << var.toStdString();
188
 
            if(var.trimmed()=="0"){
189
 
                Buffer::showwarnings=false;
190
 
                //cout << "defaults are false";
191
 
            }
192
 
            else{
193
 
                Buffer::showwarnings=true;
194
 
                //cout << "defaults are true";
195
 
            }
196
 
        }
197
 
 
198
 
        if(linenum==9){
199
 
            var=thisline.remove(0, 12);
200
 
            //cout << "Years to show: " << var.toStdString();
201
 
            Buffer::entryrange=var.trimmed();
202
 
        }
203
 
 
204
 
        if(linenum==10){
205
 
            var=thisline.remove(0, 13);
206
 
            //cout << "Default host: " << var.toStdString();
207
 
            Buffer::defaulthost=var.trimmed();
208
 
 
209
 
        }
210
 
 
211
 
        if(linenum==11){
212
 
            var=thisline.remove(0, 11);
213
 
            //cout << "Default database: " << var.toStdString();
214
 
            Buffer::defaultdatabase=var.trimmed();
215
 
        }
216
 
 
217
 
        if(linenum==12){
218
 
            var=thisline.remove(0, 13);
219
 
            //cout << "Default user: " << var.toStdString();
220
 
            Buffer::defaultuser=var.trimmed();
221
 
        }
222
 
 
223
 
        if(linenum==13){
224
 
            var=thisline.remove(0,8);
225
 
            Buffer::databaseport=var.trimmed();
226
 
        }
227
 
 
228
 
        // sort by day
229
 
        if(linenum==14){
230
 
            var=thisline.remove(0,12);
231
 
            //cout << "Sort by day: " << var.toStdString();
232
 
 
233
 
            if(var.trimmed()=="0"){
234
 
                Buffer::sortbyday=false;
235
 
            }
236
 
            else{
237
 
                 Buffer::sortbyday=true;
238
 
            }
239
 
        }
240
 
 
241
 
        // Use alternate colors
242
 
        if(linenum==15){
243
 
            var=thisline.remove(0,17);
244
 
            //cout << "Sort by day: " << var.toStdString();
245
 
 
246
 
            if(var.trimmed()=="0"){
247
 
                Buffer::alternate_rows=false;
248
 
            }
249
 
            else{
250
 
                 Buffer::alternate_rows=true;
251
 
            }
252
 
        }
253
 
 
254
 
        // Use background
255
 
        if(linenum==16){
256
 
            var=thisline.remove(0,15);
257
 
            //cout << "Sort by day: " << var.toStdString();
258
 
 
259
 
            if(var.trimmed()=="0"){
260
 
                Buffer::use_background=false;
261
 
            }
262
 
            else{
263
 
                 Buffer::use_background=true;
264
 
            }
265
 
        }
266
 
 
267
 
        // Use theme
268
 
        if(linenum==17){
269
 
            var=thisline.remove(0,10);
270
 
            //cout << "Sort by day: " << var.toStdString();
271
 
 
272
 
            if(var.trimmed()=="0"){
273
 
                Buffer::use_custom_theme=false;
274
 
            }
275
 
            else{
276
 
                 Buffer::use_custom_theme=true;
277
 
            }
278
 
        }
279
 
 
280
 
        // tile Background
281
 
        if(linenum==18){
282
 
            var=thisline.remove(0,16);
283
 
            //cout << "Sort by day: " << var.toStdString();
284
 
 
285
 
            if(var.trimmed()=="0"){
286
 
                Buffer::tile_bg=false;
287
 
            }
288
 
            else{
289
 
                 Buffer::tile_bg=true;
290
 
            }
291
 
        }
292
 
 
293
 
        // Apply background to tree
294
 
        if(linenum==19){
295
 
            var=thisline.remove(0,16);
296
 
            //cout << "Sort by day: " << var.toStdString();
297
 
 
298
 
            if(var.trimmed()=="0"){
299
 
                Buffer::set_tree_background=false;
300
 
            }
301
 
            else{
302
 
                 Buffer::set_tree_background=true;
303
 
            }
304
 
        }
305
 
 
306
 
        // Font color
307
 
        if(linenum==20){
308
 
            var=thisline.remove(0,11);
309
 
            //cout << "Sort by day: " << var.toStdString();
310
 
 
311
 
            if(var.trimmed()=="NULL"){
312
 
                Buffer::text_hexcolor.clear();
313
 
            }
314
 
            else{
315
 
                Buffer::text_hexcolor=var.trimmed();
316
 
            }
317
 
        }
318
 
 
319
 
        // Font face
320
 
        if(linenum==21){
321
 
            var=thisline.remove(0,10);
322
 
            //cout << "Sort by day: " << var.toStdString();
323
 
 
324
 
            if(var.trimmed()=="NULL"){
325
 
                Buffer::font_face.clear();
326
 
            }
327
 
            else{
328
 
                Buffer::font_face=var.trimmed();
329
 
            }
330
 
        }
331
 
 
332
 
        // Font size
333
 
        if(linenum==22){
334
 
            var=thisline.remove(0,10);
335
 
            //cout << "Sort by day: " << var.toStdString();
336
 
 
337
 
            if(var.trimmed()=="NULL"){
338
 
                Buffer::font_size="12";
339
 
            }
340
 
            else{
341
 
                Buffer::font_size=var.trimmed();
342
 
            }
343
 
        }
344
 
 
345
 
        // Record time of entries
346
 
        if(linenum==23){
347
 
            var=thisline.remove(0,9);
348
 
            //cout << "Sort by day: " << var.toStdString();
349
 
 
350
 
            if(var.trimmed()=="0"){
351
 
                Buffer::keep_time=false;
352
 
            }
353
 
            else{
354
 
                 Buffer::keep_time=true;
355
 
            }
356
 
        }
357
 
 
358
 
        // Use Local Time
359
 
        if(linenum==24){
360
 
            var=thisline.remove(0,11);
361
 
            //cout << "Sort by day: " << var.toStdString();
362
 
 
363
 
            if(var.trimmed()=="0"){
364
 
                Buffer::use_system_time=false;
365
 
            }
366
 
            else{
367
 
                 Buffer::use_system_time=true;
368
 
            }
369
 
        }
370
 
 
371
 
        // Show title
372
 
        if(linenum==25){
373
 
            var=thisline.remove(0,11);
374
 
            //cout << "Sort by day: " << var.toStdString();
375
 
 
376
 
            if(var.trimmed()=="0"){
377
 
                Buffer::show_title=false;
378
 
            }
379
 
            else{
380
 
                 Buffer::show_title=true;
381
 
            }
382
 
        }
383
 
 
384
 
        // Use 24 hour clock
385
 
        if(linenum==26){
386
 
            var=thisline.remove(0,8);
387
 
            //cout << "Sort by day: " << var.toStdString();
388
 
 
389
 
            if(var.trimmed()=="0"){
390
 
                Buffer::use_24_hour=false;
391
 
            }
392
 
            else{
393
 
                 Buffer::use_24_hour=true;
394
 
            }
395
 
        }
396
 
 
397
 
        // Load Date format
398
 
        if(linenum==27){
399
 
            var=thisline.remove(0,12);
400
 
            //cout << "Sort by day: " << var.toStdString();
401
 
 
402
 
            Buffer::date_format=var.trimmed();
403
 
        }
404
 
 
405
 
        // support rich text
406
 
        if(linenum==28){
407
 
            var=thisline.remove(0,10);
408
 
            //cout << "Sort by day: " << var.toStdString();
409
 
 
410
 
            if(var.trimmed()=="0"){
411
 
                Buffer::rich_text=false;
412
 
            }
413
 
            else{
414
 
                 Buffer::rich_text=true;
415
 
            }
416
 
        }
417
 
 
418
 
        // Load background image
419
 
        if(linenum==29){
420
 
            var=thisline.remove(0,17);
421
 
            //cout << "Sort by day: " << var.toStdString();
422
 
 
423
 
            Buffer::background_image=var.trimmed();
424
 
        }
425
 
 
426
 
        // Load icon labels
427
 
        if(linenum==30){
428
 
            var=thisline.remove(0,12);
429
 
            //cout << "Sort by day: " << var.toStdString();
430
 
 
431
 
            if(var.trimmed()=="0"){
432
 
                Buffer::show_icon_labels=false;
433
 
            }
434
 
            else{
435
 
                 Buffer::show_icon_labels=true;
436
 
            }
437
 
 
438
 
 
439
 
        }
440
 
 
441
 
    }
442
 
 
443
 
    configfile.close();
444
 
 
445
 
    cout << "Done!" << endl;
446
 
    cout << "OUTPUT: Stage 1 completed, proceeding to Stage 2..." << endl;
447
 
 
448
 
 
449
 
}
450
 
 
451
 
// Save changes made in Config class to config file
452
 
void ConfigManager::WriteConfig(){
453
 
 
454
 
}
455
 
 
456
 
// Function to rebuild config file if it is missing
457
 
void ::ConfigManager::RebuildConfig(){
458
 
 
459
 
    using namespace std;
460
 
    directory.setPath(configpath);
461
 
 
462
 
    // directory check
463
 
    if(!directory.exists()){
464
 
        cout << "Rebuilding config file directory: " << configpath.toStdString() << endl;
465
 
        directory.mkdir(configpath);
466
 
 
467
 
 
468
 
    }
469
 
    else{
470
 
        cout << "OUTPUT: Config directory already exists, proceeding...";
471
 
    }
472
 
 
473
 
    // once the directory exists, proceed to create the config file and write some default values to it
474
 
 
475
 
     cout  << "OUTPUT: Creating new config file: robojournal.cfg..." << endl;
476
 
     cout  << "OUTPUT: Populating robojournal.cfg with default values..." << endl;
477
 
     QString sysuser=getenv("USERNAME");
478
 
     if (configfile.open(QIODevice::ReadWrite)) {
479
 
             QTextStream stream(&configfile);
480
 
             stream << "ROBOJOURNAL CONFIGURATION v0.2" << endl;
481
 
             stream << "#########################################" << endl;
482
 
             stream << "TOOLBAR_LOCATION:1" << endl;
483
 
             stream << "ALLOW_ROOT_LOGINS:0" << endl;
484
 
             stream << "SHOW_ALL_ENTRIES:1" << endl;
485
 
             stream << "ALWAYS_USE_DEFAULTS:1" << endl;
486
 
             stream << "DB_TYPE:MySQL" << endl;
487
 
             stream << "SHOW_WARNINGS:1" << endl;
488
 
             stream << "ENTRY_RANGE:2" << endl;
489
 
             stream << "DEFAULT_HOST:localhost" << endl;
490
 
             stream << "DEFAULT_DB:"+sysuser+"_journal" << endl;
491
 
             stream << "DEFAULT_USER:" + sysuser << endl; // use default system user name
492
 
             stream << "DB_PORT:3306" << endl;
493
 
             stream << "SORT_BY_DAY:0" << endl;
494
 
             stream << "ALTERNATE_COLORS:1"<< endl;
495
 
             stream << "USE_BACKGROUND:0"<< endl;
496
 
             stream << "USE_THEME:0"<< endl;
497
 
             stream << "TILE_BACKGROUND:1"<< endl;
498
 
             stream << "BACKGROUND_TREE:0"<< endl;
499
 
             stream << "FONT_COLOR:#000000"<< endl;
500
 
             stream << "FONT_FACE:"<< endl;
501
 
             stream << "FONT_SIZE:12"<< endl;
502
 
             stream << "USE_TIME:1"<< endl;
503
 
             stream << "LOCAL_TIME:1"<< endl;
504
 
             stream << "SHOW_TITLE:1"<< endl;
505
 
             stream << "24_HOUR:0"<< endl;
506
 
             stream << "DATE_FORMAT:0"<< endl;
507
 
             stream << "RICH_TEXT:0"<< endl;
508
 
             stream << "BACKGROUND_IMAGE:NULL"<< endl;
509
 
             stream << "ICON_LABELS:1"<< endl;
510
 
 
511
 
             configfile.close();
512
 
         }
513
 
     cout << "OUTPUT: Config file successfully replaced!" << endl;
514
 
     cout << "OUTPUT: Attempting re-read of config file..." <<endl;
515
 
     ReadConfig();
516
 
     configfile.close();
517
 
}
518
 
 
519
 
// This function updates the config file with new settings.
520
 
// It should always be invoked from the Config class, since the Config::$var
521
 
// static variables are assigned in the Config class.
522
 
 
523
 
void ConfigManager::UpdateConfig(){
524
 
 
525
 
 
526
 
    // rewrite values in config file.
527
 
    if(!configfile.isOpen()){
528
 
        if (configfile.open(QIODevice::ReadWrite)) {
529
 
            QTextStream stream(&configfile);
530
 
            stream << "ROBOJOURNAL CONFIGURATION v0.2" << endl;
531
 
            stream << "#########################################" << endl;
532
 
            stream << "TOOLBAR_LOCATION:" << Config::new_toolbar_pos.trimmed() << endl;
533
 
            stream << "ALLOW_ROOT_LOGINS:" << Config::new_allow_root.trimmed() << endl;
534
 
            stream << "SHOW_ALL_ENTRIES:" << Config::new_show_all_entries.trimmed() << endl;
535
 
            stream << "ALWAYS_USE_DEFAULTS:" << Config::new_always_use_defaults.trimmed() << endl;
536
 
            stream << "DB_TYPE:" << Config::new_dbtype.trimmed() << endl;
537
 
            stream << "SHOW_WARNINGS:" << Config::new_show_confirm.trimmed() << endl;
538
 
            stream << "ENTRY_RANGE:" << Config::new_entry_range.trimmed() << endl;
539
 
            stream << "DEFAULT_HOST:" << Config::new_default_host.trimmed() << endl;
540
 
            stream << "DEFAULT_DB:" << Config::new_default_db.trimmed() << endl;
541
 
            stream << "DEFAULT_USER:" << Config::new_default_user.trimmed() << endl;
542
 
            stream << "DB_PORT:" << Config::new_default_port.trimmed() << endl;
543
 
            stream << "SORT_BY_DAY:" << Config::new_sort_by_day.trimmed() << endl;
544
 
            stream << "ALTERNATE_COLORS:"<< Config::new_alternate_rows.trimmed() << endl;
545
 
            stream << "USE_BACKGROUND:"<< Config::new_use_background.trimmed() << endl;
546
 
            stream << "USE_THEME:"<< Config::new_use_custom_theme.trimmed() << endl;
547
 
            stream << "TILE_BACKGROUND:"<< Config::new_tile_bg.trimmed() << endl;
548
 
            stream << "BACKGROUND_TREE:"<< Config::new_use_background_in_tree.trimmed() << endl;
549
 
            stream << "FONT_COLOR:"<< Config::new_text_hexcolor.trimmed() << endl;
550
 
            stream << "FONT_FACE:"<< Config::new_font_face.trimmed() << endl;
551
 
            stream << "FONT_SIZE:"<< Config::new_font_size.trimmed() << endl;
552
 
            stream << "USE_TIME:"<< Config::new_record_time.trimmed() <<  endl;
553
 
            stream << "LOCAL_TIME:"<< Config::new_use_local_time.trimmed() << endl;
554
 
            stream << "SHOW_TITLE:"<< Config::new_show_title.trimmed() << endl;
555
 
            stream << "24_HOUR:"<< Config::new_24_hr.trimmed() << endl;
556
 
            stream << "DATE_FORMAT:"<< Config::new_date_mode.trimmed() << endl;
557
 
            stream << "RICH_TEXT:"<< Config::new_rich_text.trimmed() << endl;
558
 
            stream << "BACKGROUND_IMAGE:" << Config::new_background_image.trimmed() << endl;
559
 
            stream << "ICON_LABELS:" << Config::new_icon_labels.trimmed() << endl;
560
 
 
561
 
            // Bugfix: always overwrite any junk data at the end of the config file with blank lines
562
 
            stream << "" << endl;
563
 
            stream << "" << endl;
564
 
            stream << "" << endl;
565
 
            stream << "" << endl;
566
 
 
567
 
            configfile.close();
568
 
 
569
 
            // Replace old data in Buffer
570
 
            ConfigManager::ReadConfig();
571
 
        }
572
 
    }
573
 
    else{ // show error if robojournal.cfg is open
574
 
        QMessageBox h;
575
 
        h.critical(NULL,"Error","RoboJournal is not able to modify the configuration because " +
576
 
                   config_name + " is in use by another process!");
577
 
 
578
 
    } 
579
 
}
580
 
 
581
 
/*
582
 
  CustomSetup() takes data from the Journal Creator class or the Journal Locator
583
 
 class and uses it to create the config file. This function is supposed to replace
584
 
 RebuildConfig() for most purposes. Now, RebuildConfig() only gets called if you're connecting to
585
 
 an existing database at first run.
586
 
*/
587
 
 
588
 
void ConfigManager::CustomSetup(QString host,QString db_name, QString port, QString newuser){
589
 
 
590
 
    using namespace std;
591
 
    directory.setPath(configpath);
592
 
 
593
 
    // directory check
594
 
    if(!directory.exists()){
595
 
        cout << "Rebuilding config file directory: " << configpath.toStdString() << endl;
596
 
        directory.mkdir(configpath);
597
 
 
598
 
 
599
 
    }
600
 
    else{
601
 
        cout << "OUTPUT: Config directory already exists, proceeding...";
602
 
    }
603
 
 
604
 
    // once the directory exists, proceed to create the config file and write some default values to it
605
 
 
606
 
     cout  << "OUTPUT: Creating new config file: robojournal.cfg..." << endl;
607
 
     cout  << "OUTPUT: Populating robojournal.cfg with values from setup form..." << endl;
608
 
 
609
 
     if (configfile.open(QIODevice::ReadWrite)) {
610
 
             QTextStream stream(&configfile);
611
 
             stream << "ROBOJOURNAL CONFIGURATION v0.2" << endl;
612
 
             stream << "#########################################" << endl;
613
 
             stream << "TOOLBAR_LOCATION:1" << endl;
614
 
             stream << "ALLOW_ROOT_LOGINS:0" << endl;
615
 
             stream << "SHOW_ALL_ENTRIES:1" << endl;
616
 
             stream << "ALWAYS_USE_DEFAULTS:1" << endl;
617
 
             stream << "DB_TYPE:MySQL" << endl;
618
 
             stream << "SHOW_WARNINGS:1" << endl;
619
 
             stream << "ENTRY_RANGE:2" << endl;
620
 
             stream << "DEFAULT_HOST:" << host << endl;
621
 
             stream << "DEFAULT_DB:"<< db_name << endl;
622
 
             stream << "DEFAULT_USER:" + newuser << endl; // use default system user name
623
 
             stream << "DB_PORT:" << port << endl;
624
 
             stream << "SORT_BY_DAY:0" << endl;
625
 
             stream << "ALTERNATE_COLORS:1"<< endl;
626
 
             stream << "USE_BACKGROUND:0"<< endl;
627
 
             stream << "USE_THEME:0"<< endl;
628
 
             stream << "TILE_BACKGROUND:1"<< endl;
629
 
             stream << "BACKGROUND_TREE:0"<< endl;
630
 
             stream << "FONT_COLOR:#000000"<< endl;
631
 
             stream << "FONT_FACE:"<< endl;
632
 
             stream << "FONT_SIZE:12"<< endl;
633
 
             stream << "USE_TIME:1"<< endl;
634
 
             stream << "LOCAL_TIME:1"<< endl;
635
 
             stream << "SHOW_TITLE:1"<< endl;
636
 
             stream << "24_HOUR:0"<< endl;
637
 
             stream << "DATE_FORMAT:0"<< endl;
638
 
             stream << "RICH_TEXT:0"<< endl;
639
 
             stream << "BACKGROUND_IMAGE:NULL"<< endl;
640
 
             stream << "ICON_LABELS:1"<< endl;
641
 
             configfile.close();
642
 
         }
643
 
     cout << "OUTPUT: Config file successfully replaced!" << endl;
644
 
     cout << "OUTPUT: Attempting re-read of config file..." <<endl;
645
 
     ReadConfig();
646
 
     configfile.close();
647
 
}
648
 
 
649
 
 
650