examples/ForumNokia/Symbian_OS_End-to-End_Sockets_API_Example/SocketTaskManager_S60/engine/Request.cpp

00001 /*
00002 * ============================================================================
00003 *  Name     : TRequest from Request.cpp
00004 *  Part of  : TaskManager
00005 *  Created  : 15/03/2006 by Forum Nokia
00006 *  Version  : 1.2
00007 *  Copyright: Nokia Corporation
00008 * ============================================================================
00009 */
00010 
00011 // INCLUDE FILES
00012 #include "Request.h"
00013 #include "TaskManager.pan"
00014 
00015 // CONSTANTS
00016 _LIT(KTab, "\t");
00017 _LIT(KLineEnd, "\n");
00018 _LIT(KSeparator, "#");
00019 
00020 _LIT(KFetchCommand, "fetch");
00021 _LIT(KMarkCommand, "mark");
00022 
00023 _LIT(KUnknownOperation, "Unknown operation!");
00024 
00025 // ================= MEMBER FUNCTIONS =======================
00026 
00027 // ----------------------------------------------------
00028 // CRequest::GetMessage()
00029 // Static parser function that returns a descriptor containing
00030 // a client message that the server end understands.
00031 // ----------------------------------------------------
00032 //      
00033 void TRequest::GetMessage( TDesC& aUsername, TDesC& aPassword,
00034                                TRequest::TOperationType aOperation,
00035                                TDesC& aId, TDes8& aMessage )
00036     {
00037         // A valid command string is built
00038         // Format: username#password#operation[#id]
00039     aMessage.Zero();
00040     
00041         aMessage.Append( aUsername );
00042         aMessage.Append( KSeparator );
00043         aMessage.Append( aPassword );
00044         aMessage.Append( KSeparator );
00045 
00046         switch( aOperation )
00047         {
00048                 case TRequest::EFetchTasks:
00049                 {
00050                         aMessage.Append( KFetchCommand );
00051                         break;
00052                 }
00053                 case TRequest::ETaskDone:
00054                 {
00055                         aMessage.Append( KMarkCommand );
00056                         aMessage.Append( KSeparator );
00057                 aMessage.Append( aId );
00058                         break;
00059                 }
00060                 default:
00061                 {
00062                         User::Panic( KUnknownOperation, ETaskManagerInvalidTask );
00063                 }
00064         }
00065         
00066         aMessage.Append( KLineEnd );
00067     }
00068 
00069 // End of file

Generated by  doxygen 1.6.2