summaryrefslogtreecommitdiffstats
path: root/libkmime/tests/test_mdn.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /libkmime/tests/test_mdn.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkmime/tests/test_mdn.cpp')
-rw-r--r--libkmime/tests/test_mdn.cpp151
1 files changed, 151 insertions, 0 deletions
diff --git a/libkmime/tests/test_mdn.cpp b/libkmime/tests/test_mdn.cpp
new file mode 100644
index 000000000..1bb387f1d
--- /dev/null
+++ b/libkmime/tests/test_mdn.cpp
@@ -0,0 +1,151 @@
+#include <kmime_mdn.h>
+using namespace KMime::MDN;
+
+#include <qcstring.h>
+#include <qstring.h>
+#include <qvaluelist.h>
+
+#include <iostream>
+using std::cout;
+using std::cerr;
+#include <cstdlib>
+using std::exit;
+using std::endl;
+
+#define _GNU_SOURCE 1
+#include <getopt.h>
+
+void usage( const char * msg=0 ) {
+ if ( msg )
+ cerr << msg << endl;
+ cerr << "usage: test_mdn <options>\n"
+ "where options include the following:" << endl
+ << "FIXME" << endl;
+ exit( 1 );
+}
+
+int main( int argc, char * argv[] ) {
+
+ QString finalRecipient;
+ QString originalRecipient;
+ QCString originalMessageId;
+ ActionMode actionMode = ManualAction;
+ SendingMode sendingMode = SentManually;
+ DispositionType dispositionType = Displayed;
+ QValueList<DispositionModifier> dispositionModifiers;
+ QString special;
+
+ while ( true ) {
+ int option_index = 0;
+ static const struct option long_options[] = {
+ { "action-mode", 1, 0, 'a' },
+ { "disposition-type", 1, 0, 'd' },
+ { "final-recipient", 1, 0, 'f' },
+ { "original-message-id", 1, 0, 'i' },
+ { "disposition-modifiers", 1, 0, 'm' },
+ { "original-recipient", 1, 0, 'o' },
+ { "sending-mode", 1, 0, 's' },
+ { 0, 0, 0, 0 }
+ };
+
+ int c = getopt_long( argc, argv, "a:d:f:i:m:o:s:",
+ long_options, &option_index );
+ if ( c == -1 ) break;
+
+#define EQUALS(x) !qstricmp( optarg, x )
+
+ switch ( c ) {
+
+ case 'a': // --action-mode
+ if ( EQUALS( "manual-action" ) )
+ actionMode = ManualAction;
+ else if ( EQUALS( "automatic-action" ) )
+ actionMode = AutomaticAction;
+ else
+ usage( "unknown action mode!" );
+ break;
+
+ case 'd': // --disposition-type
+ if ( EQUALS( "displayed" ) )
+ dispositionType = Displayed;
+ else if ( EQUALS( "deleted" ) )
+ dispositionType = Deleted;
+ else if ( EQUALS( "dispatched" ) )
+ dispositionType = Dispatched;
+ else if ( EQUALS( "processed" ) )
+ dispositionType = Processed;
+ else if ( EQUALS( "denied" ) )
+ dispositionType = Denied;
+ else if ( EQUALS( "failed" ) )
+ dispositionType = Failed;
+ else
+ usage( "unknown disposition type!" );
+ break;
+
+ case 'f': // --final-recipient
+ if ( optarg && *optarg )
+ finalRecipient = QString::fromUtf8( optarg );
+ else
+ usage( "--final-recipient is missing a value" );
+ break;
+
+ case 'i': // --original-message-id
+ if ( optarg && *optarg )
+ originalMessageId = optarg;
+ else
+ usage( "--original-message-id is missing a value" );
+ break;
+
+ case 'm': // --disposition-modifier
+ if ( EQUALS( "error" ) )
+ dispositionModifiers << Error;
+ else if ( EQUALS( "warning" ) )
+ dispositionModifiers << Warning;
+ else if ( EQUALS( "superseded" ) )
+ dispositionModifiers << Superseded;
+ else if ( EQUALS( "expired" ) )
+ dispositionModifiers << Expired;
+ else if ( EQUALS( "mailbox-terminated" ) )
+ dispositionModifiers << MailboxTerminated;
+ else
+ usage( "unknwon disposition modifier!" );
+ break;
+
+ case 'o': // --original-recipient
+ if ( optarg && *optarg )
+ originalRecipient = QString::fromUtf8( optarg );
+ else
+ usage( "--original-recipient is missing a value" );
+ break;
+
+ case 's': // --sending-mode
+ if ( EQUALS( "MDN-sent-manually" ) )
+ sendingMode = SentManually;
+ else if ( EQUALS( "MDN-sent-automatically" ) )
+ sendingMode = SentAutomatically;
+ else
+ usage( "unknown sending mode" );
+ break;
+
+ default:
+ usage( "unknown option encountered!" );
+ }
+ }
+
+ if ( optind < argc )
+ special = QString::fromUtf8( argv[optind++] );
+ if ( optind < argc )
+ usage( "too many arguments!" );
+
+ QCString result = dispositionNotificationBodyContent( finalRecipient,
+ originalRecipient.latin1(),
+ originalMessageId,
+ dispositionType,
+ actionMode,
+ sendingMode,
+ dispositionModifiers,
+ special );
+ cout << "Result:\n" << result.data();
+
+ return 0;
+}