00001 #ifndef UDPNOTIFY_H 00002 #define UDPNOTIFY_H 00003 00004 #include <qstring.h> 00005 #include <qmap.h> 00006 #include <pthread.h> 00007 #include <qvaluevector.h> 00008 #include <qvaluelist.h> 00009 #include <qdom.h> 00010 00011 #include <qsocketdevice.h> 00012 #include <qsocketnotifier.h> 00013 #include <qhostaddress.h> 00014 00015 #include <qobject.h> 00016 #include <vector> 00017 using namespace std; 00018 00019 00020 class TV; 00021 class OSD; 00022 class UDPNotifyOSDTypeText; 00023 00024 class UDPNotifyOSDSet 00025 { 00026 public: 00027 UDPNotifyOSDSet(const QString &name); 00028 ~UDPNotifyOSDSet(); 00029 00030 UDPNotifyOSDTypeText *GetType(const QString &name); 00031 void AddType(UDPNotifyOSDTypeText *type, QString name); 00032 void ResetTypes(void); 00033 QString GetName(void); 00034 vector<UDPNotifyOSDTypeText *> *GetTypeList(); 00035 00036 private: 00037 QString m_name; 00038 QMap<QString, UDPNotifyOSDTypeText *> typesMap; 00039 vector<UDPNotifyOSDTypeText *> *allTypes; 00040 }; 00041 00042 class UDPNotifyOSDTypeText 00043 { 00044 public: 00045 UDPNotifyOSDTypeText(const QString &name, const QString &text); 00046 ~UDPNotifyOSDTypeText(); 00047 void SetText(const QString &text); 00048 QString GetName(void); 00049 QString GetText(void); 00050 00051 private: 00052 QString m_name; 00053 QString m_text; 00054 }; 00055 00056 class UDPNotify : public QObject 00057 { 00058 Q_OBJECT 00059 00060 public: 00061 UDPNotify(TV *tv, int udp_port); 00062 ~UDPNotify(void); 00063 00064 protected slots: 00065 virtual void incomingData(int socket); 00066 00067 private: 00068 int m_udp_port; 00069 QHostAddress bcastaddr; 00070 TV *m_tv; 00071 00072 QMap<QString, UDPNotifyOSDSet *> setMap; 00073 vector<UDPNotifyOSDSet *> *setList; 00074 00075 QDomDocument doc; 00076 00077 // Socket Device for UDP communication. 00078 QSocketDevice *qsd; 00079 // Notifier, signals available data on socket. 00080 QSocketNotifier *qsn; 00081 00082 void AddSet(UDPNotifyOSDSet *set, QString name); 00083 UDPNotifyOSDSet *GetSet(const QString &text); 00084 UDPNotifyOSDSet *parseContainer(QDomElement &element); 00085 void parseTextArea(UDPNotifyOSDSet *container, QDomElement &element); 00086 QString getFirstText(QDomElement &element); 00087 00088 void ClearContainer(UDPNotifyOSDSet *container); 00089 }; 00090 00091 #endif 00092
1.5.5