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