trunk 20080912
[gitenigma.git] / src / enigma_mmi.h
blobce071f1ca7de30f8024fde788a25a709fc625f43
1 #ifndef __ENIGMA_MMI_H_
2 #define __ENIGMA_MMI_H_
4 #include <lib/gui/listbox.h>
5 #include <lib/base/message.h>
6 #include <lib/base/buffer.h>
8 class eNumber;
9 class eLabel;
10 class eTextInputField;
11 class eWindow;
12 class eStatusBar;
14 struct eMMIMsg
16 char *data;
17 int len;
18 eMMIMsg()
21 eMMIMsg(char* data, int len)
22 : data(data), len(len)
27 class eMMIEnqWindow : public eWindow
29 eLabel *title;
30 eNumber *input;
31 int num;
32 int eventHandler( const eWidgetEvent &e );
33 void okPressed(int*);
34 public:
35 eMMIEnqWindow( const eString& titleBarText, const eString &windowText, int num, bool blind );
36 eString getAnswer();
39 class eMMIListWindow : public eListBoxWindow<eListBoxEntryText>
41 eLabel *title, *subtitle, *bottomText;
42 int eventHandler( const eWidgetEvent &e );
43 public:
44 void entrySelected( eListBoxEntryText* e );
45 eMMIListWindow(const eString &titleBarText, const eString &title, const eString &subtitle, const eString &bottomText, std::list< std::pair< eString, int> > &entrys );
46 int getSelected() { return (int) list.getCurrent()->getKey(); }
49 class enigmaMMI : public eWindow
51 protected:
52 eIOBuffer buffer;
53 eFixedMessagePump<eMMIMsg> mmi_messages;
54 eWidget *open;
55 Connection conn;
56 eLabel *lText;
57 eTimer responseTimer, delayTimer, closeTimer;
58 const char *scheduledData;
59 void closeMMI();
60 enum AnswerType { ENQAnswer, MENUAnswer, LISTAnswer };
61 enigmaMMI();
62 public:
63 bool connected() { return conn.connected(); }
64 int eventHandler( const eWidgetEvent &e );
65 virtual bool handleMMIMessage(const char *data);
66 void gotMMIData(const char* data, int);
67 void handleMessage( const eMMIMsg &msg );
68 void showWaitForAnswer(int ret);
69 void hideWaitForAnswer();
70 virtual void beginExec() { }
71 virtual void endExec() { }
72 virtual void sendAnswer( AnswerType ans, int param, unsigned char *data )=0;
73 void haveScheduledData();
76 #endif //__ENIGMA_MMI_H_