source: SMSSender/src/main.cpp @ 42:63df32d07e95

3.0
Last change on this file since 42:63df32d07e95 was 42:63df32d07e95, checked in by Sämy Zehnder <saemy.zehnder@…>, 12 years ago
  • Rearranged util- and data-type-class-files (Created libdatatypes, libutils)
  • Started with translation of SwisscomXtraZone? strings
  • New contactList fetches now names as well as aliases.
  • Segmentationfault in SwisscomXtraZone?-plugin is fixed.
  • Started with account->enabled() stuff.
  • It's not really usable at the moment, but its getting better :)

(Had some conflicts before -> the last commits are connected to this one)

File size: 2.4 KB
Line 
1#include "ui/VCMain/vcmain.h"
2
3#include <QtGui>
4#include <QApplication>
5
6#include <cxxtools/loginit.h>
7
8#include <QString>
9#include <QtPlugin>
10
11#include "business/BCSettings.h"
12#include "business/BCAccountManager.h"
13#include "business/BCGatewayManager.h"
14#include "business/BCLibraryLoader.h"
15
16//Q_IMPORT_PLUGIN(interfaces)
17
18void loadGateways() {
19    // TODO: Exception handling
20    QDir gatewayPath(qApp->applicationDirPath());
21    #if defined(Q_OS_WIN)
22        if (gatewayPath.dirName().toLower() == "debug" || gatewayPath.dirName().toLower() == "release")
23            gatewayPath.cdUp();
24    #elif defined(Q_OS_MAC)
25        if (gatewayPath.dirName() == "MacOS") {
26            gatewayPath.cdUp();
27            gatewayPath.cdUp();
28            gatewayPath.cdUp();
29        }
30    #endif
31    gatewayPath.cd("gateways");
32
33    BCGatewayManager::instance()->loadGatewaysFromLibraryPath(gatewayPath);
34}
35
36void loadAccounts() {
37    // TODO: Exception handling
38    BCAccountManager::instance()->readAccountsFromStorage();
39    BCAccountManager::instance()->accountLoadManager()->loadAccounts(BCAccountManager::instance()->getAccountList());
40}
41
42void sendTestSMS(){
43/*    IContact* c = BCContactManager::instance()->getContact(1);
44    QSet<IContact*> recipients;
45    recipients.insert(c);
46
47    IAccount* ac = BCAccountManager::instance()->getAccount(1);
48    ac->sendSMS("testmsg", recipients);*/
49}
50
51int main(int argc, char *argv[]){
52    log_init();
53
54    QApplication a(argc, argv);
55
56    /* Load the translator */
57    QLocale locale = BCSettings::instance()->getLocale();
58
59    QTranslator qtTranslator;
60    qtTranslator.load("qt_" + locale.name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
61    a.installTranslator(&qtTranslator);
62
63    QTranslator myTranslator;
64    if (myTranslator.load(locale.name(), BCSettings::instance()->getLocalePath())){
65        a.installTranslator(&myTranslator);
66    }
67
68    VCMain w;
69    /* Center the window */
70    int scrn = QApplication::desktop()->screenNumber(&w);
71    QRect desk(QApplication::desktop()->availableGeometry(scrn));
72    w.move((desk.width() - w.width()) / 2,
73           (desk.height() - w.height()) / 2);
74
75    /* And finally show it */
76    w.show();
77
78
79    loadGateways();
80
81    foreach (ILibrary* library, BCLibraryLoader::instance()->libraries()) {
82        QTranslator* translator = library->getTranslator(locale);
83        if (!translator->isEmpty()){
84            a.installTranslator(translator);
85        }
86    }
87
88    loadAccounts();
89
90    return a.exec();
91}
Note: See TracBrowser for help on using the repository browser.