00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <qfile.h>
00026
00027 #include <kapplication.h>
00028 #include <dcopclient.h>
00029 #include <kaboutdata.h>
00030 #include <kcmdlineargs.h>
00031 #include <klocale.h>
00032 #include <kdebug.h>
00033 #include <kmessagebox.h>
00034
00035 #include "modem.h"
00036 #include "kandy.h"
00037 #include "mobilemain.h"
00038 #include "mobilegui.h"
00039 #include "commandscheduler.h"
00040 #include "kandyprefs.h"
00041
00042 static const char description[] =
00043 I18N_NOOP("Communicating with your mobile phone.");
00044
00045 static const char version[] = "0.5.1";
00046
00047 static KCmdLineOptions options[] =
00048 {
00049 { "terminal", I18N_NOOP("Show terminal window"), 0 },
00050 { "mobilegui", I18N_NOOP("Show mobile GUI"), 0 },
00051 { "nogui", I18N_NOOP("Do not show GUI"), 0 },
00052 { "+[profile]", I18N_NOOP("Filename of command profile file"), 0 },
00053 KCmdLineLastOption
00054 };
00055
00056 void initModem(Modem *modem)
00057 {
00058 kdDebug() << "Opening serial Device: "
00059 << KandyPrefs::serialDevice()
00060 << endl;
00061
00062 modem->setSpeed( KandyPrefs::baudRate().toUInt() );
00063 modem->setData(8);
00064 modem->setParity('N');
00065 modem->setStop(1);
00066
00067 #if 0
00068 if (!modem->dsrOn()) {
00069 KMessageBox::sorry(this, i18n("Modem is off."), i18n("Modem Error"));
00070 modem->close();
00071 return;
00072 }
00073 if (!modem->ctsOn()) {
00074 KMessageBox::sorry(this, i18n("Modem is busy."), i18n("Modem Error"));
00075 modem->close();
00076 return;
00077 }
00078 #endif
00079
00080 #if 0
00081 modem->writeLine("");
00082 usleep(250000);
00083 modem->flush();
00084 modem->writeLine("ATZ");
00085 #endif
00086 }
00087
00088 int main(int argc, char **argv)
00089 {
00090 KAboutData about("kandy", I18N_NOOP("Kandy"), version, description,
00091 KAboutData::License_GPL, "(C) 2001 Cornelius Schumacher",0,
00092 "http://kandy.kde.org/");
00093 about.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" );
00094 about.addAuthor( "Heiko Falk", 0, "hf2@ls12.cs.uni-dortmund.de" );
00095 KCmdLineArgs::init(argc,argv,&about);
00096 KCmdLineArgs::addCmdLineOptions(options);
00097
00098 KApplication app;
00099 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00100
00101
00102 app.dcopClient()->registerAs(app.name(),false);
00103
00104 Modem *modem = new Modem(KandyPrefs::self());
00105 CommandScheduler *scheduler = new CommandScheduler(modem);
00106
00107
00108 if (app.isRestored()) {
00109
00110
00111 } else
00112 {
00113
00114 Kandy *k = new Kandy(scheduler);
00115
00116 MobileMain *m = new MobileMain(scheduler, KandyPrefs::self());
00117
00118 if (!args->isSet("gui")) {
00119 } else {
00120 if (KandyPrefs::startupTerminalWin() ||
00121 args->isSet("terminal")) {
00122 k->show();
00123 }
00124 if (KandyPrefs::startupMobileWin() ||
00125 args->isSet("mobilegui")) {
00126 m->show();
00127 }
00128 }
00129
00130 if (args->count() == 1) {
00131 k->load(QFile::decodeName(args->arg(0)));
00132 } else if (args->count() > 1) {
00133 args->usage();
00134 }
00135
00136 args->clear();
00137
00138 QObject::connect(k,SIGNAL(showMobileWin()),m,SLOT(show()));
00139 QObject::connect(m,SIGNAL(showTerminalWin()),k,SLOT(show()));
00140 QObject::connect(m,SIGNAL(showPreferencesWin()),
00141 k,SLOT(optionsPreferences()));
00142
00143 QObject::connect( m->view(), SIGNAL( connectModem() ), k,
00144 SLOT( modemConnect() ) );
00145 QObject::connect( m->view(), SIGNAL( disconnectModem() ), k,
00146 SLOT( modemDisconnect() ) );
00147
00148 QObject::connect( modem, SIGNAL( errorMessage( const QString & ) ),
00149 k, SLOT( showErrorMessage( const QString & ) ) );
00150
00151 initModem( modem );
00152
00153 if ( KandyPrefs::startupModem() )
00154 m->view()->toggleConnection();
00155 }
00156
00157 return app.exec();
00158 }