00001 00002 // Program Name: upnptasknotify.h 00003 // 00004 // Purpose - UPnp Task to send Notification messages 00005 // 00006 // Created By : David Blain Created On : Oct. 24, 2005 00007 // Modified By : Modified On: 00008 // 00010 00011 #ifndef __UPNPTASKNOTIFY_H__ 00012 #define __UPNPTASKNOTIFY_H__ 00013 00014 // POSIX headers 00015 #include <sys/types.h> 00016 #ifndef USING_MINGW 00017 #include <netinet/in.h> 00018 #include <arpa/inet.h> 00019 #endif 00020 00021 // Qt headers 00022 #include <qsocketdevice.h> 00023 00024 // MythTV headers 00025 #include "upnp.h" 00026 #include "multicast.h" 00027 #include "compat.h" 00028 00030 // Typedefs 00032 00033 typedef enum 00034 { 00035 NTS_alive = 0, 00036 NTS_byebye = 1 00037 00038 } UPnpNotifyNTS; 00039 00042 // 00043 // UPnpNotifyTask Class Definition 00044 // 00047 00048 class UPnpNotifyTask : public Task 00049 { 00050 protected: 00051 00052 QMutex m_mutex; 00053 00054 QString m_sMasterIP; 00055 int m_nServicePort; 00056 int m_nMaxAge; 00057 00058 UPnpNotifyNTS m_eNTS; 00059 00060 protected: 00061 00062 // Destructor protected to force use of Release Method 00063 00064 virtual ~UPnpNotifyTask(); 00065 00066 void ProcessDevice( QSocketDevice *pSocket, UPnpDevice *pDevice ); 00067 void SendNotifyMsg( QSocketDevice *pSocket, QString sNT, QString sUDN ); 00068 00069 public: 00070 00071 UPnpNotifyTask( int nServicePort ); 00072 00073 virtual QString Name () { return( "Notify" ); } 00074 virtual void Execute( TaskQueue * ); 00075 00076 // ------------------------------------------------------------------ 00077 00078 QString GetNTSString() 00079 { 00080 m_mutex.lock(); 00081 UPnpNotifyNTS nts = m_eNTS; 00082 m_mutex.unlock(); 00083 00084 switch( nts ) 00085 { 00086 case NTS_alive : return( "ssdp:alive" ); 00087 case NTS_byebye: return( "ssdp:byebye" ); 00088 } 00089 return( "unknown" ); 00090 } 00091 00092 // ------------------------------------------------------------------ 00093 00094 UPnpNotifyNTS GetNTS() 00095 { 00096 m_mutex.lock(); 00097 UPnpNotifyNTS nts = m_eNTS; 00098 m_mutex.unlock(); 00099 00100 return( nts ); 00101 } 00102 00103 // ------------------------------------------------------------------ 00104 00105 void SetNTS( UPnpNotifyNTS nts) 00106 { 00107 m_mutex.lock(); 00108 m_eNTS = nts; 00109 m_mutex.unlock(); 00110 } 00111 00112 }; 00113 00114 00115 #endif
1.5.5