Use tqtinterface-provided values for DCOP text types

This resolves Bug 994
pull/16/head
Timothy Pearson 12 years ago
parent 76684764d9
commit 2366375b23

@ -145,31 +145,31 @@ TQCString demarshal( TQDataStream &stream, const TQString &type )
bool b; bool b;
stream >> b; stream >> b;
result = b ? "true" : "false"; result = b ? "true" : "false";
} else if ( type == "TQString" ) } else if ( type == TQSTRING_OBJECT_NAME_STRING )
{ {
TQString s; TQString s;
stream >> s; stream >> s;
result = s.local8Bit(); result = s.local8Bit();
} else if ( type == "TQCString" ) } else if ( type == TQCSTRING_OBJECT_NAME_STRING )
{ {
stream >> result; stream >> result;
} else if ( type == "QCStringList" ) } else if ( type == "QCStringList" )
{ {
return demarshal( stream, "TQValueList<TQCString>" ); return demarshal( stream, TQVALUELIST_OBJECT_NAME_STRING "<" TQCSTRING_OBJECT_NAME_STRING ">" );
} else if ( type == "TQStringList" ) } else if ( type == TQSTRINGLIST_OBJECT_NAME_STRING )
{ {
return demarshal( stream, "TQValueList<TQString>" ); return demarshal( stream, TQVALUELIST_OBJECT_NAME_STRING "<" TQCSTRING_OBJECT_NAME_STRING ">" );
} else if ( type == "TQColor" ) } else if ( type == TQCOLOR_OBJECT_NAME_STRING )
{ {
TQColor c; TQColor c;
stream >> c; stream >> c;
result = TQString(c.name()).local8Bit(); result = TQString(c.name()).local8Bit();
} else if ( type == "TQSize" ) } else if ( type == TQSIZE_OBJECT_NAME_STRING )
{ {
TQSize s; TQSize s;
stream >> s; stream >> s;
result.sprintf( "%dx%d", s.width(), s.height() ); result.sprintf( "%dx%d", s.width(), s.height() );
} else if ( type == "TQPixmap" || type == "TQImage" ) } else if ( type == TQPIXMAP_OBJECT_NAME_STRING || type == TQIMAGE_OBJECT_NAME_STRING )
{ {
TQImage i; TQImage i;
stream >> i; stream >> i;
@ -178,17 +178,17 @@ TQCString demarshal( TQDataStream &stream, const TQString &type )
buf.open( IO_WriteOnly ); buf.open( IO_WriteOnly );
i.save( &buf, "XPM" ); i.save( &buf, "XPM" );
result = buf.buffer(); result = buf.buffer();
} else if ( type == "TQPoint" ) } else if ( type == TQPOINT_OBJECT_NAME_STRING )
{ {
TQPoint p; TQPoint p;
stream >> p; stream >> p;
result.sprintf( "+%d+%d", p.x(), p.y() ); result.sprintf( "+%d+%d", p.x(), p.y() );
} else if ( type == "TQRect" ) } else if ( type == TQRECT_OBJECT_NAME_STRING )
{ {
TQRect r; TQRect r;
stream >> r; stream >> r;
result.sprintf( "%dx%d+%d+%d", r.width(), r.height(), r.x(), r.y() ); result.sprintf( "%dx%d+%d+%d", r.width(), r.height(), r.x(), r.y() );
} else if ( type == "TQVariant" ) } else if ( type == TQVARIANT_OBJECT_NAME_STRING )
{ {
TQ_INT32 type; TQ_INT32 type;
stream >> type; stream >> type;
@ -203,7 +203,7 @@ TQCString demarshal( TQDataStream &stream, const TQString &type )
KURL r; KURL r;
stream >> r; stream >> r;
result = r.url().local8Bit(); result = r.url().local8Bit();
} else if ( type.left( 11 ) == "TQValueList<" ) } else if ( type.left( 11 ) == TQVALUELIST_OBJECT_NAME_STRING "<" )
{ {
if ( (uint)type.find( '>', 11 ) != type.length() - 1 ) if ( (uint)type.find( '>', 11 ) != type.length() - 1 )
return result; return result;
@ -225,7 +225,7 @@ TQCString demarshal( TQDataStream &stream, const TQString &type )
if ( i < count - 1 ) if ( i < count - 1 )
result += '\n'; result += '\n';
} }
} else if ( type.left( 5 ) == "TQMap<" ) } else if ( type.left( 5 ) == TQMAP_OBJECT_NAME_STRING "<" )
{ {
int commaPos = type.find( ',', 5 ); int commaPos = type.find( ',', 5 );
@ -278,10 +278,10 @@ void marshall( TQDataStream &arg, QCStringList args, uint &i, TQString type )
} }
TQString s = TQString::fromLocal8Bit( args[ i ] ); TQString s = TQString::fromLocal8Bit( args[ i ] );
if (type == "TQStringList") if (type == TQSTRINGLIST_OBJECT_NAME_STRING)
type = "TQValueList<TQString>"; type = TQVALUELIST_OBJECT_NAME_STRING "<" TQSTRING_OBJECT_NAME_STRING ">";
if (type == "QCStringList") if (type == "QCStringList")
type = "TQValueList<TQCString>"; type = TQVALUELIST_OBJECT_NAME_STRING "<" TQSTRING_OBJECT_NAME_STRING ">";
if ( type == "int" ) if ( type == "int" )
arg << s.toInt(); arg << s.toInt();
@ -317,36 +317,36 @@ void marshall( TQDataStream &arg, QCStringList args, uint &i, TQString type )
arg << s.toDouble(); arg << s.toDouble();
else if ( type == "bool" ) else if ( type == "bool" )
arg << mkBool( s ); arg << mkBool( s );
else if ( type == "TQString" ) else if ( type == TQSTRING_OBJECT_NAME_STRING )
arg << s; arg << s;
else if ( type == "TQCString" ) else if ( type == TQCSTRING_OBJECT_NAME_STRING )
arg << TQCString( args[ i ] ); arg << TQCString( args[ i ] );
else if ( type == "TQColor" ) else if ( type == TQCOLOR_OBJECT_NAME_STRING )
arg << mkColor( s ); arg << mkColor( s );
else if ( type == "TQPoint" ) else if ( type == TQPOINT_OBJECT_NAME_STRING )
arg << mkPoint( s ); arg << mkPoint( s );
else if ( type == "TQSize" ) else if ( type == TQSIZE_OBJECT_NAME_STRING )
arg << mkSize( s ); arg << mkSize( s );
else if ( type == "TQRect" ) else if ( type == TQRECT_OBJECT_NAME_STRING )
arg << mkRect( s ); arg << mkRect( s );
else if ( type == "KURL" ) else if ( type == "KURL" )
arg << KURL( s ); arg << KURL( s );
else if ( type == "TQVariant" ) { else if ( type == TQVARIANT_OBJECT_NAME_STRING ) {
if ( s == "true" || s == "false" ) if ( s == "true" || s == "false" )
arg << TQVariant( mkBool( s ), 42 ); arg << TQVariant( mkBool( s ), 42 );
else if ( s.left( 4 ) == "int(" ) else if ( s.left( 4 ) == "int(" )
arg << TQVariant( s.mid(4, s.length()-5).toInt() ); arg << TQVariant( s.mid(4, s.length()-5).toInt() );
else if ( s.left( 7 ) == "TQPoint(" ) else if ( s.left( 7 ) == TQPOINT_OBJECT_NAME_STRING "(" )
arg << TQVariant( mkPoint( s.mid(7, s.length()-8) ) ); arg << TQVariant( mkPoint( s.mid(7, s.length()-8) ) );
else if ( s.left( 6 ) == "TQSize(" ) else if ( s.left( 6 ) == TQSIZE_OBJECT_NAME_STRING "(" )
arg << TQVariant( mkSize( s.mid(6, s.length()-7) ) ); arg << TQVariant( mkSize( s.mid(6, s.length()-7) ) );
else if ( s.left( 6 ) == "TQRect(" ) else if ( s.left( 6 ) == TQRECT_OBJECT_NAME_STRING "(" )
arg << TQVariant( mkRect( s.mid(6, s.length()-7) ) ); arg << TQVariant( mkRect( s.mid(6, s.length()-7) ) );
else if ( s.left( 7 ) == "TQColor(" ) else if ( s.left( 7 ) == TQCOLOR_OBJECT_NAME_STRING "(" )
arg << TQVariant( mkColor( s.mid(7, s.length()-8) ) ); arg << TQVariant( mkColor( s.mid(7, s.length()-8) ) );
else else
arg << TQVariant( s ); arg << TQVariant( s );
} else if ( type.startsWith("TQValueList<") || } else if ( type.startsWith(TQVALUELIST_OBJECT_NAME_STRING "<") ||
type == "KURL::List" ) { type == "KURL::List" ) {
if ( type == "KURL::List" ) if ( type == "KURL::List" )
type = "KURL"; type = "KURL";

@ -47,7 +47,7 @@ TQCString& replyType, TQByteArray &replyData)
gettimeofday(&tv, 0); gettimeofday(&tv, 0);
tqWarning("%s: function('%s') %d:%06d", name(), m_remoteName.data(), tv.tv_sec % 100, tv.tv_usec); tqWarning("%s: function('%s') %d:%06d", name(), m_remoteName.data(), tv.tv_sec % 100, tv.tv_usec);
replyType = "TQString"; replyType = TQSTRING_OBJECT_NAME_STRING;
TQDataStream reply( replyData, IO_WriteOnly ); TQDataStream reply( replyData, IO_WriteOnly );
reply << TQString("Hey"); reply << TQString("Hey");
m_timer.start(1000, true); m_timer.start(1000, true);

@ -238,7 +238,7 @@ inline TQDataStream & operator << (TQDataStream & str, const DCOPArg& arg )
* dcopTypeName function, for example * dcopTypeName function, for example
* *
* \code * \code
* inline const char* dcopTypeName( const TQString& ) { return "TQString"; } * inline const char* dcopTypeName( const TQString& ) { return TQSTRING_OBJECT_NAME_STRING; }
* \endcode * \endcode
* *
* If you use custom data types that do support TQDataStream but have * If you use custom data types that do support TQDataStream but have

@ -37,38 +37,38 @@ inline const char* dcopTypeName( long ) { return "long int"; }
inline const char* dcopTypeName( ulong ) { return "ulong"; } inline const char* dcopTypeName( ulong ) { return "ulong"; }
inline const char* dcopTypeName( double ) { return "double"; } inline const char* dcopTypeName( double ) { return "double"; }
inline const char* dcopTypeName( float ) { return "float"; } inline const char* dcopTypeName( float ) { return "float"; }
inline const char* dcopTypeName( const char* ) { return "TQCString"; } inline const char* dcopTypeName( const char* ) { return TQCSTRING_OBJECT_NAME_STRING; }
// dcop specialities // dcop specialities
class DCOPRef; inline const char* dcopTypeName( const DCOPRef& ) { return "DCOPRef"; } class DCOPRef; inline const char* dcopTypeName( const DCOPRef& ) { return "DCOPRef"; }
// Qt variant types // Qt variant types
class TQString; inline const char* dcopTypeName( const TQString& ) { return "TQString"; } class TQString; inline const char* dcopTypeName( const TQString& ) { return TQSTRING_OBJECT_NAME_STRING; }
class TQCString; inline const char* dcopTypeName( const TQCString& ) { return "TQCString"; } class TQCString; inline const char* dcopTypeName( const TQCString& ) { return TQCSTRING_OBJECT_NAME_STRING; }
class TQFont; inline const char* dcopTypeName( const TQFont& ) { return "TQFont"; } class TQFont; inline const char* dcopTypeName( const TQFont& ) { return TQFONT_OBJECT_NAME_STRING; }
class TQPixmap; inline const char* dcopTypeName( const TQPixmap& ) { return "TQPixmap"; } class TQPixmap; inline const char* dcopTypeName( const TQPixmap& ) { return TQPIXMAP_OBJECT_NAME_STRING; }
class TQBrush; inline const char* dcopTypeName( const TQBrush& ) { return "TQBrush"; } class TQBrush; inline const char* dcopTypeName( const TQBrush& ) { return TQBRUSH_OBJECT_NAME_STRING; }
class TQRect; inline const char* dcopTypeName( const TQRect& ) { return "TQRect"; } class TQRect; inline const char* dcopTypeName( const TQRect& ) { return TQRECT_OBJECT_NAME_STRING; }
class TQPoint; inline const char* dcopTypeName( const TQPoint& ) { return "TQPoint"; } class TQPoint; inline const char* dcopTypeName( const TQPoint& ) { return TQPOINT_OBJECT_NAME_STRING; }
class TQImage; inline const char* dcopTypeName( const TQImage& ) { return "TQImage"; } class TQImage; inline const char* dcopTypeName( const TQImage& ) { return TQIMAGE_OBJECT_NAME_STRING; }
class TQSize; inline const char* dcopTypeName( const TQSize& ) { return "TQSize"; } class TQSize; inline const char* dcopTypeName( const TQSize& ) { return TQSIZE_OBJECT_NAME_STRING; }
class TQColor; inline const char* dcopTypeName( const TQColor& ) { return "TQColor"; } class TQColor; inline const char* dcopTypeName( const TQColor& ) { return TQCOLOR_OBJECT_NAME_STRING; }
class TQPalette; inline const char* dcopTypeName( const TQPalette& ) { return "TQPalette"; } class TQPalette; inline const char* dcopTypeName( const TQPalette& ) { return TQPALETTE_OBJECT_NAME_STRING; }
class TQColorGroup; inline const char* dcopTypeName( const TQColorGroup& ) { return "TQColorGroup"; } class TQColorGroup; inline const char* dcopTypeName( const TQColorGroup& ) { return TQCOLORGROUP_OBJECT_NAME_STRING; }
class TQIconSet; inline const char* dcopTypeName( const TQIconSet& ) { return "TQIconSet"; } class TQIconSet; inline const char* dcopTypeName( const TQIconSet& ) { return TQICONSET_OBJECT_NAME_STRING; }
class TQDataStream; inline const char* dcopTypeName( const TQDataStream& ) { return "TQDataStream"; } class TQDataStream; inline const char* dcopTypeName( const TQDataStream& ) { return TQDATASTREAM_OBJECT_NAME_STRING; }
class TQPointArray; inline const char* dcopTypeName( const TQPointArray& ) { return "TQPointArray"; } class TQPointArray; inline const char* dcopTypeName( const TQPointArray& ) { return TQPOINTARRAY_OBJECT_NAME_STRING; }
class TQRegion; inline const char* dcopTypeName( const TQRegion& ) { return "TQRegion"; } class TQRegion; inline const char* dcopTypeName( const TQRegion& ) { return TQREGION_OBJECT_NAME_STRING; }
class TQBitmap; inline const char* dcopTypeName( const TQBitmap& ) { return "TQBitmap"; } class TQBitmap; inline const char* dcopTypeName( const TQBitmap& ) { return TQBITMAP_OBJECT_NAME_STRING; }
class TQCursor; inline const char* dcopTypeName( const TQCursor& ) { return "TQCursor"; } class TQCursor; inline const char* dcopTypeName( const TQCursor& ) { return TQCURSOR_OBJECT_NAME_STRING; }
class TQStringList; inline const char* dcopTypeName( const TQStringList& ) { return "TQStringList"; } class TQStringList; inline const char* dcopTypeName( const TQStringList& ) { return TQSTRINGLIST_OBJECT_NAME_STRING; }
class TQSizePolicy; inline const char* dcopTypeName( const TQSizePolicy& ) { return "TQSizePolicy"; } class TQSizePolicy; inline const char* dcopTypeName( const TQSizePolicy& ) { return TQSIZEPOLICY_OBJECT_NAME_STRING; }
class TQDate; inline const char* dcopTypeName( const TQDate& ) { return "TQDate"; } class TQDate; inline const char* dcopTypeName( const TQDate& ) { return TQDATE_OBJECT_NAME_STRING; }
class TQTime; inline const char* dcopTypeName( const TQTime& ) { return "TQTime"; } class TQTime; inline const char* dcopTypeName( const TQTime& ) { return TQTIME_OBJECT_NAME_STRING; }
class TQDateTime; inline const char* dcopTypeName( const TQDateTime& ) { return "TQDateTime"; } class TQDateTime; inline const char* dcopTypeName( const TQDateTime& ) { return TQDATETIME_OBJECT_NAME_STRING; }
class TQBitArray; inline const char* dcopTypeName( const TQBitArray& ) { return "TQBitArray"; } class TQBitArray; inline const char* dcopTypeName( const TQBitArray& ) { return TQBITARRAY_OBJECT_NAME_STRING; }
class TQKeySequence; inline const char* dcopTypeName( const TQKeySequence& ) { return "TQKeySequence"; } class TQKeySequence; inline const char* dcopTypeName( const TQKeySequence& ) { return TQKEYSEQUENCE_OBJECT_NAME_STRING; }
class TQVariant; inline const char* dcopTypeName( const TQVariant& ) { return "TQVariant"; } class TQVariant; inline const char* dcopTypeName( const TQVariant& ) { return TQVARIANT_OBJECT_NAME_STRING; }
// And some KDE types // And some KDE types
class KURL; inline const char* dcopTypeName( const KURL& ) { return "KURL"; } class KURL; inline const char* dcopTypeName( const KURL& ) { return "KURL"; }

@ -57,7 +57,7 @@ bool MyDCOPObject::process(const TQCString &fun, const TQByteArray &data,
printf("Rect x = %d, y = %d, w = %d, h = %d\n", arg1.x(), arg1.y(), arg1.width(), arg1.height()); printf("Rect x = %d, y = %d, w = %d, h = %d\n", arg1.x(), arg1.y(), arg1.width(), arg1.height());
replyType = "TQRect"; replyType = TQRECT_OBJECT_NAME_STRING;
TQDataStream reply( replyData, IO_WriteOnly ); TQDataStream reply( replyData, IO_WriteOnly );
TQRect r(10,20,100,200); TQRect r(10,20,100,200);
reply << r; reply << r;
@ -74,7 +74,7 @@ bool MyDCOPObject::process(const TQCString &fun, const TQByteArray &data,
tqDebug("countDown() countDownAction = %p", countDownAction); tqDebug("countDown() countDownAction = %p", countDownAction);
if (countDownAction2) if (countDownAction2)
{ {
replyType = "TQString"; replyType = TQSTRING_OBJECT_NAME_STRING;
TQDataStream reply( replyData, IO_WriteOnly ); TQDataStream reply( replyData, IO_WriteOnly );
reply << TQString("Hey"); reply << TQString("Hey");
return true; return true;
@ -104,7 +104,7 @@ void MyDCOPObject::slotTimeout()
countDownCount--; countDownCount--;
if (countDownCount == 0) if (countDownCount == 0)
{ {
TQCString replyType = "TQString"; TQCString replyType = TQSTRING_OBJECT_NAME_STRING;
TQByteArray replyData; TQByteArray replyData;
TQDataStream reply( replyData, IO_WriteOnly ); TQDataStream reply( replyData, IO_WriteOnly );
reply << TQString("Hello World"); reply << TQString("Hello World");
@ -123,7 +123,7 @@ void MyDCOPObject::slotTimeout2()
countDownCount2--; countDownCount2--;
if (countDownCount2 == 0) if (countDownCount2 == 0)
{ {
TQCString replyType = "TQString"; TQCString replyType = TQSTRING_OBJECT_NAME_STRING;
TQByteArray replyData; TQByteArray replyData;
TQDataStream reply( replyData, IO_WriteOnly ); TQDataStream reply( replyData, IO_WriteOnly );
reply << TQString("Hello World"); reply << TQString("Hello World");
@ -139,7 +139,7 @@ void MyDCOPObject::slotTimeout2()
QCStringList MyDCOPObject::functions() QCStringList MyDCOPObject::functions()
{ {
QCStringList result = DCOPObject::functions(); QCStringList result = DCOPObject::functions();
result << "TQRect canLaunchRockets(TQRect)"; result << TQRECT_OBJECT_NAME_STRING " canLaunchRockets(" TQRECT_OBJECT_NAME_STRING ")";
return result; return result;
} }

Loading…
Cancel
Save