[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdeextragear-3/kdebluetooth/libqobex/qobexclient [POSSIBLY UNSAFE]
From: Mathias Fröhlich <Mathias.Froehlich () web ! de>
Date: 2004-08-28 7:21:33
Message-ID: 20040828072133.AA2372158 () office ! kde ! org
[Download RAW message or body]
CVS commit by froehlich:
Add commandline switch and implementation to dump the raw obex packets
into a file.
A client.cpp 1.1 [POSSIBLY UNSAFE: printf] [LGPL (v2+)]
A client.h 1.1 [LGPL (v2+)]
M +2 -2 Makefile.am 1.4
M +13 -50 qobexclient.cpp 1.6 [POSSIBLY UNSAFE: printf]
--- kdeextragear-3/kdebluetooth/libqobex/qobexclient/Makefile.am #1.3:1.4
@@ -2,5 +2,5 @@
# This file is part of libqobex.
#
-# Copyright (c) 2003 Mathias Froehlich <Mathias.Froehlich@web.de>
+# Copyright (c) 2003-2004 Mathias Froehlich <Mathias.Froehlich@web.de>
#
# This library is free software; you can redistribute it and/or
@@ -24,5 +24,5 @@
bin_PROGRAMS = qobexclient
-qobexclient_SOURCES = qobexclient.cpp
+qobexclient_SOURCES = qobexclient.cpp client.cpp
qobexclient_LDADD = ../qobex/libqobex.la $(LIB_QT)
--- kdeextragear-3/kdebluetooth/libqobex/qobexclient/qobexclient.cpp #1.5:1.6
@@ -43,7 +43,8 @@
#include <qobex/qobexirdatransport.h>
#endif
-#include <qobex/qobexclient.h>
#include <qobex/qobexuuid.h>
+#include "client.h"
+
#define ARGV0 "qobexclient"
@@ -55,5 +56,5 @@ void print_usage()
fprintf( stderr, " usage:\n" );
fprintf( stderr, "\n" );
- fprintf( stderr, " " ARGV0 " [-ghlnpv] [-d dest] [-f localfile] [-m mimetype]\n" );
+ fprintf( stderr, " " ARGV0 " [-ghlnpv] [-d dest] [-D dumpfile] [-f localfile] [-m mimetype]\n" );
fprintf( stderr, " [-s speed] [-t transport] [-u uuid]\n" );
fprintf( stderr, "\n" );
@@ -81,4 +82,7 @@ void print_usage()
fprintf( stderr, " which offers the required service.\n" );
fprintf( stderr, "\n" );
+ fprintf( stderr, " -D dumpfile\n" );
+ fprintf( stderr, " Dump raw obex packets into dumpfile.\n" );
+ fprintf( stderr, "\n" );
fprintf( stderr, " -f localfile\n" );
fprintf( stderr, " The local filename to use. Defaults to stdout/stdin.\n" );
@@ -148,50 +152,4 @@ void print_usage()
}
-class client
- : public QObexClient {
-public:
- client( QObexTransport * transport, QFile * f, bool verbose )
- : QObexClient( transport ), mFile( f ), mVerbose( verbose ) {}
-
- void response( const QObexObject& resp ) {
- if ( mVerbose ) {
- fprintf( stderr, "Got Response Packet\n %s\n",
- (const char *)QFile::encodeName( resp.stringCode() ) );
- QValueList<QObexHeader> hdrs = resp.getHeaders();
- QValueList<QObexHeader>::Iterator it;
- for ( it = hdrs.begin(); it != hdrs.end(); ++it )
- fprintf( stderr, " %s\n",
- (const char *)QFile::encodeName( (*it).stringHeaderId() ) );
- }
- }
- bool dataReq( QByteArray& data, size_t max ) {
- data.resize( max );
- int ret = mFile->readBlock( data.data(), max );
- data.resize( ret );
- return 0 <= ret;
- }
- bool data( const QValueList<QByteArray>& data ) {
- if ( !data.isEmpty() ) {
- QValueList<QByteArray>::ConstIterator it;
- for ( it = data.begin(); it != data.end(); ++it ) {
- if ( 0 < (*it).size() ) {
- if ( 0 > mFile->writeBlock( (*it).data(), (*it).size() ) )
- return false;
- }
- }
- }
- return true;
- }
- void authenticationRequired( const QString& realm ) {
- if ( mVerbose ) {
- fprintf( stderr, "Got Authentication Required with realm \"%s\"\n",
- (const char *)QFile::encodeName( realm ) );
- }
- }
-private:
- QFile* mFile;
- bool mVerbose;
-};
-
extern char *optarg;
extern int optind;
@@ -212,4 +170,5 @@ int main( int argc, char **argv )
QFile file;
+ QFile dumpFile;
QString mimetype;
@@ -231,5 +190,5 @@ int main( int argc, char **argv )
int c;
- while ((c = getopt( argc, argv, "a:cd:f:ghilm:nopr:s:t:u:v" )) != EOF)
+ while ((c = getopt( argc, argv, "a:cd:D:f:ghilm:nopr:s:t:u:v" )) != EOF)
switch ( c ) {
case 'a':
@@ -242,4 +201,8 @@ int main( int argc, char **argv )
dest = QFile::decodeName( optarg );
break;
+ case 'D':
+ dumpFile.setName( QFile::decodeName( optarg ) );
+ dumpFile.open( IO_WriteOnly );
+ break;
case 'f':
{
@@ -449,5 +412,5 @@ int main( int argc, char **argv )
}
- client obex( transport, &file, verbose );
+ client obex( transport, &file, &dumpFile, verbose );
obex.setOpenObexSupport( openobex );
switch ( uuid ) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic