00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #ifndef __UPNPUTIL_H__
00012 #define __UPNPUTIL_H__
00013
00014 #include <qptrlist.h>
00015 #include <qstringlist.h>
00016 #include <qmap.h>
00017
00018 #include "compat.h"
00019
00021
00023
00024 template <class T> inline const T& Min( const T &x, const T &y )
00025 {
00026 return( ( x < y ) ? x : y );
00027 }
00028
00029 template <class T> inline const T& Max( const T &x, const T &y )
00030 {
00031 return( ( x > y ) ? x : y );
00032 }
00034
00036
00037 typedef struct timeval TaskTime;
00038 typedef QMap< QString, QString > QStringMap;
00039
00041
00042 class NameValue;
00043
00044 class NameValueList : public QPtrList< NameValue >
00045 {
00046 public:
00047
00048 NameValueList()
00049 {
00050 setAutoDelete( true );
00051 }
00052 };
00053
00054 class NameValue
00055 {
00056 public:
00057
00058 QString sName;
00059 QString sValue;
00060
00061 NameValueList *pAttributes;
00062
00063 NameValue()
00064 : sName( NULL ), sValue( NULL ), pAttributes( NULL ) { }
00065
00066 NameValue( const QString &name, const QString &value )
00067 : sName( name ), sValue( value ), pAttributes( NULL ) { }
00068
00069 NameValue( const QString &name, char *value )
00070 : sName( name ), sValue( value ), pAttributes( NULL ) { }
00071
00072 NameValue( const QString &name, int value )
00073 : sName( name ), sValue( QString::number( value )), pAttributes( NULL ) { }
00074
00075 NameValue( const QString &name, bool value )
00076 : sName( name ), sValue( (value) ? "1" : "0" ), pAttributes( NULL ) { }
00077
00078 ~NameValue()
00079 {
00080 if (pAttributes != NULL)
00081 delete pAttributes;
00082 }
00083
00084 void AddAttribute( const QString &name, const QString &value )
00085 {
00086 if (pAttributes == NULL)
00087 pAttributes = new NameValueList();
00088
00089 pAttributes->append( new NameValue( name, value ));
00090 }
00091
00092 };
00093
00095
00097
00098 QString LookupUDN ( QString sDeviceType );
00099 long GetIPAddressList ( QStringList &sStrList );
00100
00101 bool operator< ( TaskTime t1, TaskTime t2 );
00102 bool operator== ( TaskTime t1, TaskTime t2 );
00103
00104 void AddMicroSecToTaskTime( TaskTime &t, suseconds_t uSecs );
00105 void AddSecondsToTaskTime ( TaskTime &t, long nSecs );
00106
00107 #endif