kandy

mobilegui.h
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of TQt, and distribute the resulting executable,
00022     without including the source code for TQt in the source distribution.
00023 */
00024 #ifndef MOBILEGUI_H
00025 #define MOBILEGUI_H
00026 
00027 #include <kandyiface.h>
00028 
00029 #include "mobilegui_base.h"
00030 #include "kandyprefs.h"
00031 #include "tqvaluevector.h"
00032 
00033 
00034 class CommandScheduler;
00035 class ATCommand;
00036 class AddressSyncer;
00037 
00038 
00039 class MobileGui : public MobileGui_base, virtual public KandyIface
00040 { 
00041   Q_OBJECT
00042   
00043 
00044   public:
00045     MobileGui( CommandScheduler *, KandyPrefs *kprefs, TQWidget* parent=0,
00046                const char* name=0, WFlags fl=0 );
00047     ~MobileGui();
00048 
00049     void exit();
00050 
00051   signals:
00052     void sendCommand( const TQString & );
00053     void phonebookRead();
00054 
00055     void statusMessage( const TQString & );
00056     void transienStatusMessage( const TQString & );
00057     void connectModem();
00058     void disconnectModem();
00059 
00060   public slots:
00061     void readModelInformation();
00062     void readPhonebook();
00063     void savePhonebook();
00064     void refreshStatus();
00065     void writePhonebook();
00066     void readKabc();
00067     void writeKabc();
00068     void setClock();
00069     void mergePhonebooks();
00070     void syncPhonebooks();
00071     void termAddOutput( const char *line );
00072     void toggleConnection();
00073     void deleteMobPhonebook();
00074 
00075   protected slots:
00076     void processResult( ATCommand * );
00077 
00078   private:
00079     /* Links to related classes */
00080     CommandScheduler *mScheduler;
00081     AddressSyncer *mSyncer;
00082     KandyPrefs *mPrefs;
00083     TQWidget *mparent;
00084     
00085     /* String Formatting Routines */
00086     TQString quote( const TQString & );
00087     TQString dequote( const TQString & );
00088     void formatPBName( TQString *, TQString );
00089     TQString noSpaces( const TQString & );
00090     int firstFreeIndex();
00091     TQString string2GSM( const TQString & );
00092     TQString GSM2String( const TQString & );
00093     TQString decodeSuffix( const TQString & );
00094     TQString stripWhiteSpaces( const TQString & );
00095 
00096     /* Routines for GUI updates  */
00097     void updateKabBook();
00098     void updateMobileBook();
00099     void disconnectGUI();
00100     
00101     /* Phone specific items */
00102     TQString mMobManufacturer;
00103     TQString mMobModel;
00104     unsigned int mPBStartIndex;
00105     unsigned int mPBLength;
00106     unsigned int mPBNameLength;
00107     TQValueVector<bool> mPBIndexOccupied;
00108     bool mMobHasFD;
00109     bool mMobHasLD;
00110     bool mMobHasME;
00111     bool mMobHasMT;
00112     bool mMobHasTA;
00113     bool mMobHasOW;
00114     bool mMobHasMC;
00115     bool mMobHasRC;
00116 
00117     /* Routines and Flags for asynchronous control flow */
00118     TQString mLastWriteId;
00119     bool mComingFromToggleConnection;
00120     bool mComingFromReadPhonebook;
00121     bool mComingFromSyncPhonebooks;
00122     bool mComingFromExit;
00123     void writePhonebookPostProcessing();
00124 
00125     /* Routines and elements for current state of phone books */
00126     enum ABState { UNLOADED, LOADED, MODIFIED };
00127     ABState mKabState, mMobState;
00128     void setKabState( ABState );
00129     void warnKabState( ABState );
00130     void setMobState( ABState );
00131     bool warnMobState( ABState );
00132 
00133     /* Misc */
00134     void fillPhonebook( ATCommand * );
00135 };
00136 
00137 #endif // MOBILEGUI_H