kandy Library API Documentation

main.cpp

00001 /* 00002 This file is part of Kandy. 00003 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 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 "commandscheduler.h" 00039 #include "kandyprefs.h" 00040 00041 static const char description[] = 00042 I18N_NOOP("Communicating with your mobile phone"); 00043 00044 static const char version[] = "0.3"; 00045 00046 static KCmdLineOptions options[] = 00047 { 00048 { "terminal", I18N_NOOP("Show terminal window"), 0 }, 00049 { "mobilegui", I18N_NOOP("Show mobile GUI"), 0 }, 00050 { "nogui", I18N_NOOP("Do not show GUI"), 0 }, 00051 { "+[profile]", I18N_NOOP("Filename of command profile file"), 0 }, 00052 KCmdLineLastOption // End of options. 00053 }; 00054 00055 void initModem(Modem *modem) 00056 { 00057 kdDebug(5960) << "Opening serial Device: " 00058 << KandyPrefs::serialDevice() 00059 << endl; 00060 00061 modem->setDevice(KandyPrefs::serialDevice()); 00062 modem->setSpeed(19200); 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 KCmdLineArgs::init(argc,argv,&about); 00095 KCmdLineArgs::addCmdLineOptions(options); 00096 00097 KApplication app; 00098 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 00099 00100 // register ourselves as a dcop client 00101 app.dcopClient()->registerAs(app.name(),false); 00102 00103 Modem *modem = new Modem; 00104 CommandScheduler *scheduler = new CommandScheduler(modem); 00105 00106 // see if we are starting with session management 00107 if (app.isRestored()) { 00108 // TODO: do session management 00109 // RESTORE(Kandy) 00110 } else 00111 { 00112 // no session.. just start up normally 00113 Kandy *k = new Kandy(scheduler); 00114 00115 MobileMain *m = new MobileMain(scheduler); 00116 if (!args->isSet("gui")) { 00117 } else { 00118 if (KandyPrefs::startupTerminalWin() || 00119 args->isSet("terminal")) { 00120 k->show(); 00121 } 00122 if (KandyPrefs::startupMobileWin() || 00123 args->isSet("mobilegui")) { 00124 m->show(); 00125 } 00126 } 00127 00128 if (args->count() == 1) { 00129 k->load(QFile::decodeName(args->arg(0))); 00130 } else if (args->count() > 1) { 00131 args->usage(); 00132 } 00133 00134 args->clear(); 00135 00136 QObject::connect(k,SIGNAL(showMobileWin()),m,SLOT(show())); 00137 QObject::connect(m,SIGNAL(showTerminalWin()),k,SLOT(show())); 00138 QObject::connect(m,SIGNAL(showPreferencesWin()), 00139 k,SLOT(optionsPreferences())); 00140 QObject::connect(m,SIGNAL(modemConnect()),k,SLOT(modemConnect())); 00141 QObject::connect(m,SIGNAL(modemDisconnect()),k,SLOT(modemDisconnect())); 00142 QObject::connect(k,SIGNAL(connectStateChanged(bool)), 00143 m,SLOT(setConnected(bool))); 00144 00145 QObject::connect( modem, SIGNAL( errorMessage( const QString & ) ), 00146 k, SLOT( showErrorMessage( const QString & ) ) ); 00147 00148 initModem(modem); 00149 00150 if (KandyPrefs::startupModem()) k->modemConnect(); 00151 } 00152 00153 return app.exec(); 00154 }
KDE Logo
This file is part of the documentation for kandy Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:34 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003