--- a/layers.sysdef.xml Fri Oct 15 15:05:57 2010 +0800
+++ b/layers.sysdef.xml Tue Oct 19 11:00:12 2010 +0800
@@ -83,6 +83,8 @@
<module name="from_package_definition">
<unit name="mtpcontroller" unitID="smw.mtptransports.mtpcontroller" bldFile="sf\mw\remoteconn\mtptransports\mtpcontroller\group" mrp=""/>
+ <unit name="obexprotocol" unitID="smw.obex.obexprotocol" bldFile="sf\mw\remoteconn\obex\obexprotocol\group" mrp=""/>
+ <unit name="obexextensionapi" unitID="smw.obex.obexextensionapi" bldFile="sf\mw\remoteconn\obex\obexextensionapi\group" mrp=""/>
</module>
</layer>
</systemModel>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/bwins/obexextensionapisU.DEF Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,6 @@
+EXPORTS
+ ?NewL@CObexServerPacketAccessExtension@@SAPAV1@AAVCObexServer@@AAVMObexServerRequestPacketNotify@@@Z @ 1 NONAME ; class CObexServerPacketAccessExtension * CObexServerPacketAccessExtension::NewL(class CObexServer &, class MObexServerRequestPacketNotify &)
+ ?LastError@CObexClientErrorResolver@@QBEIXZ @ 2 NONAME ; unsigned int CObexClientErrorResolver::LastError(void) const
+ ?NewL@CObexClientErrorResolver@@SAPAV1@AAVCObexClient@@@Z @ 3 NONAME ; class CObexClientErrorResolver * CObexClientErrorResolver::NewL(class CObexClient &)
+ ?NewL@CObexClientErrorResolver@@SAPAV1@AAVCObexClient@@W4TObexClientErrorResolutionSetType@@@Z @ 4 NONAME ; class CObexClientErrorResolver * CObexClientErrorResolver::NewL(class CObexClient &, enum TObexClientErrorResolutionSetType)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/eabi/obexextensionapisU.DEF Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,6 @@
+EXPORTS
+ _ZN32CObexServerPacketAccessExtension4NewLER11CObexServerR30MObexServerRequestPacketNotify @ 1 NONAME
+ _ZN24CObexClientErrorResolver4NewLER11CObexClient @ 2 NONAME
+ _ZN24CObexClientErrorResolver4NewLER11CObexClient33TObexClientErrorResolutionSetType @ 3 NONAME
+ _ZNK24CObexClientErrorResolver9LastErrorEv @ 4 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/group/bld.inf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,39 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Extension API provider for OBEX
+//
+//
+
+/**
+ @file
+*/
+
+PRJ_EXPORTS
+// Extension API headers
+../public/obexserverpacketaccessextension.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/extensionapis/obexserverpacketaccessextension.h)
+../public/mobexserverrequestpacketnotify.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/extensionapis/mobexserverrequestpacketnotify.h)
+../public/obexclienterrorresolver.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/extensionapis/obexclienterrorresolver.h)
+
+// Internal OBEX headers
+../public/mobexserverrequestpacketnotifyregister.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/mobexserverrequestpacketnotifyregister.h)
+../public/mobexclienterrorresolver.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/mobexclienterrorresolver.h)
+
+
+PRJ_MMPFILES
+obexextensionapis.mmp
+
+PRJ_TESTEXPORTS
+
+PRJ_TESTMMPFILES
+../test/headercheck/group/t_obexextensionapisheadercheck.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/group/obex_extensionapis.history.xml Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<relnotes name="OBEX Extension API">
+ <purpose>
+ </purpose>
+
+ <defect number="PDEF139836" title=".esk and .cmi files do not have header" revision="001">
+ Added copyright headers
+ </defect>
+
+</relnotes>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/group/obex_extensionapis.mrp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,25 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+component obex_extensionapis
+source \sf\mw\remoteconn\obex\obexextensionapi
+binary \sf\mw\remoteconn\obex\obexextensionapi\group all
+exports \sf\mw\remoteconn\obex\obexextensionapi\group
+notes_source \component_defs\release.src
+
+
+ipr E
+ipr T \sf\mw\remoteconn\obex\obexextensionapi\test
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/group/obexextensionapis.mmp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,46 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// obexextension.mmp
+// ObexExtension DLL
+// obexextension.dll DLL providing extension APIs for OBEX
+//
+//
+
+/**
+ @file
+*/
+
+
+TARGET obexextensionapis.dll //Recommended unpaged
+
+CAPABILITY All -Tcb
+TARGETTYPE dll
+
+UID 0x1000008d 0x10281917
+
+SOURCEPATH ../src
+SOURCE obexserverpacketaccessextension.cpp
+SOURCE obexerrorextension.cpp
+
+USERINCLUDE ../../obexprotocol/common
+USERINCLUDE ../inc
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY euser.lib
+LIBRARY obex.lib
+
+VENDORID 0x70000001
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/inc/obexextensionapifaults.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,28 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXEXTENSIONAPIFAULTS_H
+#define __OBEXEXTENSIONAPIFAULTS_H
+/**
+@file
+@internalComponent
+*/
+
+enum TObexExtensionApiFaultCode
+ {
+ EInterfaceInstanceIsANullPointer = 0,
+ };
+
+#endif // __OBEXEXTENSIONAPIFAULTS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/mobexclienterrorresolver.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,47 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __MOBEXCLIENTERRORRESOLVER_H
+#define __MOBEXCLIENTERRORRESOLVER_H
+
+#include <obex/extensionapis/obexclienterrorresolver.h>
+
+/**
+UID with which applications can request the MObexClientErrorResolver API
+through CObexClient::ExtensionInterface().
+*/
+const TUid KObexClientErrorResolverInterface = {0x10281918};
+
+/**
+Definition of the Obex client error extension API.
+*/
+class MObexClientErrorResolver
+ {
+public:
+ /**
+ Function used to retreive an extended error code for the last completed client operation.
+
+ @param aErrorSet The set of errors that the resolved error will lie within.
+ @return An extended error code that lies within the error set specified.
+ */
+ virtual TUint LastError(TObexClientErrorResolutionSetType aErrorSet) const = 0;
+ };
+
+#endif __MOBEXCLIENTERRORRESOLVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/mobexserverrequestpacketnotify.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,90 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef OBEXSERVERREQUESTPACKETNOTIFY_H
+#define OBEXSERVERREQUESTPACKETNOTIFY_H
+
+#include <e32std.h>
+#include <obexbase.h>
+
+class TObexConnectInfo;
+
+typedef TUint8 TObexRequestCode;
+
+const TObexRequestCode KObexRequestFinalConnect = 0x80;
+const TObexRequestCode KObexRequestFinalDisconnect = 0x81;
+const TObexRequestCode KObexRequestPut = 0x02;
+const TObexRequestCode KObexRequestFinalPut = 0x82;
+const TObexRequestCode KObexRequestGet = 0x03;
+const TObexRequestCode KObexRequestFinalGet = 0x83;
+const TObexRequestCode KObexFinalSetPath = 0x85;
+const TObexRequestCode KObexFinalAbort = 0xFF;
+
+/**
+A Mixin to provide a notification interface for the receipt of request
+packets by an OBEX server.
+
+@publishedPartner
+@released
+*/
+class MObexServerRequestPacketNotify
+ {
+public:
+
+ /**
+ Receipt of a generic request packet.
+
+ @param aRequest The opcode of the request packet received.
+ @param aResponse The implementer should set this to the response they
+ want to send to the client if they are abandoning
+ processing.
+ @return EFalse to abandon processing the packet, ETrue to process as normal
+ */
+ virtual TBool RequestPacket(TObexRequestCode aRequest, TObexResponse& aResponse) = 0;
+
+ /**
+ Receipt of a Connect Request packet. Overload of the generic case.
+
+ @param aRequest The opcode of the Connect Request packet received.
+ @param aConnectInfo The Connect Info of the Connect Request packet.
+ @param aResponse The implementer should set this to the response they
+ want to send to the client if they are abandoning
+ processing.
+ @return EFalse to abandon processing the packet, ETrue to process as normal
+ */
+ virtual TBool RequestPacket(TObexRequestCode aRequest, TObexConnectInfo& aConnectInfo, TObexResponse& aResponse) = 0;
+
+ /**
+ Receipt of a SetPath Request packet. Overload of the generic case.
+
+ @param aRequest The opcode of the SetPath Request packet received.
+ @param aSetPathInfo The SetPath Info of the SetPath Request packet.
+ @param aResponse The implementer should set this to the response they
+ want to send to the client if they are abandoning
+ processing.
+ @return EFalse to abandon processing the packet, ETrue to process as normal
+ */
+ virtual TBool RequestPacket(TObexRequestCode aRequest, CObex::TSetPathInfo& aSetPathInfo, TObexResponse& aResponse) = 0;
+
+ };
+
+#endif // OBEXSERVERREQUESTPACKETNOTIFY_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/mobexserverrequestpacketnotifyregister.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,62 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef OBEXSERVERREQUESTPACKETNOTIFYREGISTER_H
+#define OBEXSERVERREQUESTPACKETNOTIFYREGISTER_H
+
+#include <e32std.h>
+
+class MObexServerRequestPacketNotify;
+
+/**
+ UID with which one can request the
+ MObexServerRequestPacketNotifyRegister API through
+ CObexServer::ExtensionInterface().
+
+ Some implementations may use KObexRequestPacketNotifyInterfaceId
+ which is considered deprecated.
+*/
+const TUid KObexServerRequestPacketNotifyRegisterInterface = {0x10274CB4};
+
+/**
+Mixin class to be implemented by instances providing a means to
+set an observer for the receipt of Obex request packets by a server.
+
+This provides part of the packet access API.
+*/
+class MObexServerRequestPacketNotifyRegister
+ {
+public:
+ /**
+ Sets the notifier to be called when an Obex server receives a request packet.
+
+ @param aRequestPacketNotify A pointer to the observer interface instance to receive the notifications.
+ */
+ virtual void SetObexServerRequestPacketObserver(MObexServerRequestPacketNotify& aRequestPacketNotify) = 0;
+
+ /**
+ Inform the Obex server that we have finished with this interface,
+ and delete the engine to allow a new one to be created.
+ */
+ virtual void DeleteObexServerRequestPacketNotifyRegister() = 0;
+ };
+
+#endif // OBEXSERVERREQUESTPACKETNOTIFYREGISTER_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/obexclienterrorresolver.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,108 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef __OBEXCLIENTERRORRESOLVER_H
+#define __OBEXCLIENTERRORRESOLVER_H
+
+#include <obexclient.h>
+
+class MObexClientErrorResolver;
+
+/**
+Types of error set that an Obex client error can be resolved to.
+*/
+enum TObexClientErrorResolutionSetType
+ {
+ /**
+ The basic error set that errors can be resolved to.
+ @see TObexClientBasicErrorResolutionSet
+ */
+ EObexClientBasicErrorResolutionSet = 0,
+ };
+
+/**
+The basic error set that errors can be resolved to.
+*/
+enum TObexClientBasicErrorResolutionSet
+ {
+ /**
+ The last client operation completed without error.
+ This value is unused but remains here for compatibility.
+ */
+ EObexNoExtendedError = 0,
+
+ /**
+ The last client operation completed without error.
+ */
+ EObexRequestAccepted = 1,
+
+ /**
+ The last client operation was unauthorised or resulted in
+ an error being returned from the server.
+ */
+ EObexRequestNotAccepted = 2,
+
+ /**
+ The last client operation timed out.
+ */
+ EObexRequestTimeout = 3,
+
+ /**
+ The last client operation was interrupted by an error
+ detected on the client side, which includes the following:
+ - Cancellation of the operation (Abort)
+ - Obex protocol error
+ - Out of memory condition
+ */
+ EObexRequestLocalInterruption = 4,
+
+ /**
+ The last client operation was interrupted due to the
+ transport link going down. This may be caused by:
+ - Failure to find a remote device capable of Obex
+ - Blocking of the IrDA beam
+ */
+ EObexRequestLinkInterruption = 5,
+ };
+
+/**
+Extension class for CObexClient that allows Obex client applications to
+retrieve an extended error code for the last completed client operation.
+*/
+NONSHARABLE_CLASS(CObexClientErrorResolver) : public CBase
+ {
+public:
+ IMPORT_C static CObexClientErrorResolver* NewL(CObexClient& aClient);
+ IMPORT_C static CObexClientErrorResolver* NewL(CObexClient& aClient, TObexClientErrorResolutionSetType aErrorSet);
+ IMPORT_C TUint LastError() const;
+
+private:
+ // Private constructor - this class is not intended for derivation.
+ CObexClientErrorResolver(CObexClient& aClient, TObexClientErrorResolutionSetType aErrorSet);
+ void ConstructL();
+
+private:
+ CObexClient& iObexClient;
+ MObexClientErrorResolver* iClientErrorResolver;
+ TObexClientErrorResolutionSetType iErrorSet;
+ };
+
+#endif // __OBEXCLIENTERRORRESOLVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/public/obexserverpacketaccessextension.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,50 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXSERVERPACKETACCESSEXTENSION_H
+#define OBEXSERVERPACKETACCESSEXTENSION_H
+
+#include <e32base.h>
+
+class CObexServer;
+class MObexServerRequestPacketNotify;
+class MObexServerRequestPacketNotifyRegister;
+
+/**
+This class provides the extension API to give an OBEX server application
+the option of registering a callback interface for being informed of
+packets the server receives before the server processes them.
+
+@publishedPartner
+@released
+*/
+NONSHARABLE_CLASS(CObexServerPacketAccessExtension) : public CBase
+ {
+public:
+ IMPORT_C static CObexServerPacketAccessExtension* NewL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify);
+
+ ~CObexServerPacketAccessExtension();
+
+private:
+ CObexServerPacketAccessExtension();
+ void ConstructL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify);
+
+private:
+ MObexServerRequestPacketNotifyRegister* iRequestPacketNotify;
+
+ };
+
+#endif // OBEXSERVERPACKETACCESSEXTENSION_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/src/obexerrorextension.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,72 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <obex/extensionapis/obexclienterrorresolver.h>
+#include <obex/internal/mobexclienterrorresolver.h>
+
+/**
+Factory function for CObexClientErrorResolver. Will leave if the associated CObexClient
+does not support this extension type.
+
+@param aClient Reference to the instance of CObexClient being extended.
+@return A pointer to a new CObexClientErrorResolver object.
+*/
+EXPORT_C CObexClientErrorResolver* CObexClientErrorResolver::NewL(CObexClient& aClient)
+ {
+ return NewL(aClient, EObexClientBasicErrorResolutionSet);
+ }
+
+/**
+Factory function for CObexClientErrorResolver. Will leave if the associated CObexClient
+does not support this extension type.
+
+@param aClient Reference to the instance of CObexClient being extended.
+@param aErrorSet The set of errors that the resolved error will lie within.
+@return A pointer to a new CObexClientErrorResolver object.
+*/
+EXPORT_C CObexClientErrorResolver* CObexClientErrorResolver::NewL(CObexClient& aClient, TObexClientErrorResolutionSetType aErrorSet)
+ {
+ CObexClientErrorResolver* self = new (ELeave)CObexClientErrorResolver(aClient, aErrorSet);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+/**
+Function used to retreive an extended error code for the last completed client operation.
+
+@return An extended error code that lies within the error set specified at construction time.
+*/
+EXPORT_C TUint CObexClientErrorResolver::LastError() const
+ {
+ return iClientErrorResolver->LastError(iErrorSet);
+ }
+
+CObexClientErrorResolver::CObexClientErrorResolver(CObexClient& aClient, TObexClientErrorResolutionSetType aErrorSet)
+ : iObexClient(aClient), iErrorSet(aErrorSet)
+ {
+ }
+
+void CObexClientErrorResolver::ConstructL()
+ {
+ iClientErrorResolver = static_cast<MObexClientErrorResolver*>(iObexClient.ExtensionInterface(KObexClientErrorResolverInterface));
+ User::LeaveIfNull(iClientErrorResolver);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/src/obexserverpacketaccessextension.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,84 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/extensionapis/obexserverpacketaccessextension.h>
+#include <obexserver.h>
+#include <obex/internal/mobexserverrequestpacketnotifyregister.h>
+#include "obexextensionapifaults.h"
+
+//Category used for internal panics
+_LIT(KPanicCat, "ObexExtApis");
+
+/**
+Factory function for CObexServerPacketAccessExtension. Will leave if the associated CObexServer
+does not support this extension type.
+
+Note that this object needs to be deleted before the CObexServer object it is registered to is
+deleted.
+
+@param aServer Reference to the instance of CObexServer being extended.
+@param aPacketNotify Reference to the instance of MObexRequestPacketNotify to be notified of
+incoming packets. Notifications will stop when this CObexServerPacketAccessExtension object is
+deleted.
+@return A pointer to a new CObexServerPacketAccessExtension object.
+*/
+EXPORT_C CObexServerPacketAccessExtension* CObexServerPacketAccessExtension::NewL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify)
+ {
+ CObexServerPacketAccessExtension* self = new (ELeave) CObexServerPacketAccessExtension();
+ CleanupStack::PushL(self);
+ self->ConstructL(aServer, aRequestPacketNotify);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+The destructor will not delete the instance of the MObexServerRequestPacketNotify
+it holds. It will signal to the CObexServer instance that packet notification is
+no longer required, and so re-allow another CObexServerPacketAccessExtension to bind
+to the CObexServer instance.
+
+This should be called before the CObexServer instance the object is registered to
+is deleted.
+*/
+CObexServerPacketAccessExtension::~CObexServerPacketAccessExtension()
+ {
+ if (iRequestPacketNotify)
+ {
+ iRequestPacketNotify->DeleteObexServerRequestPacketNotifyRegister();
+ }
+ }
+
+/**
+Constructor.
+*/
+CObexServerPacketAccessExtension::CObexServerPacketAccessExtension()
+ {
+
+ }
+
+/**
+Performs the main construction of the CObexServerPacketAccessExtension.
+
+@param aServer The CObexServer instance to register request packet notification callbacks.
+@param aRequestPacketNotify The mixin instance that will receive notification of request packets.
+*/
+void CObexServerPacketAccessExtension::ConstructL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify)
+ {
+ iRequestPacketNotify = static_cast<MObexServerRequestPacketNotifyRegister*>(aServer.ExtensionInterfaceL(KObexServerRequestPacketNotifyRegisterInterface));
+ // by here we should have a correctly cast instance, as otherwise we should have already left.
+ __ASSERT_ALWAYS(iRequestPacketNotify, User::Panic(KPanicCat, EInterfaceInstanceIsANullPointer));
+ iRequestPacketNotify->SetObexServerRequestPacketObserver(aRequestPacketNotify);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/group/t_obexextensionapisheadercheck.mmp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,43 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Pointless file produced by test project; the test is that it
+// compiles at all.
+//
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+target t_obexextensionheadercheck.exe
+targettype exe
+uid 0
+VENDORID 0x70000001
+
+sourcepath ../src
+source main.cpp
+
+source t_obexserverpacketaccessextension.cpp
+source t_mobexserverrequestpacketnotify.cpp
+source t_mobexserverrequestpacketnotifyregister.cpp
+
+source t_obexclienterrorresolver.cpp
+source t_mobexclienterrorresolver.cpp
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+library euser.lib
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/main.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,21 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32std.h>
+
+GLDEF_C TInt E32Main()
+ {
+ return KErrNone;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_mobexclienterrorresolver.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/mobexclienterrorresolver.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_mobexserverrequestpacketnotify.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/extensionapis/mobexserverrequestpacketnotify.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_mobexserverrequestpacketnotifyregister.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/mobexserverrequestpacketnotifyregister.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_obexclienterrorresolver.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/extensionapis/obexclienterrorresolver.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexextensionapi/test/headercheck/src/t_obexserverpacketaccessextension.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/extensionapis/obexserverpacketaccessextension.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/bld.inf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,26 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// OBject EXchange Protocol
+//
+//
+
+/**
+ @file
+*/
+
+// Main
+#include "group/bld.inf"
+
+// Extension APIs
+#include "../obexextensionapi/group/bld.inf"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/common/logger.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,163 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// All rights reserved.
+//
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#ifndef LOGGER_H
+#define LOGGER_H
+
+#include <e32base.h>
+
+// Control function entry and exit logging using a compile-time switch.
+//#define __LOG_FUNCTIONS__
+
+// Dump contents of packets using a compile-time switch.
+//#define __LOG_PACKET_DUMP__
+
+class TFunctionLogger;
+
+#ifndef __COMMSDEBUGUTILITY_H__ // comms-infras/commsdebugutility.h not included
+#ifdef _DEBUG // If this is a debug build...
+// Set flogging active.
+#define __FLOG_ACTIVE
+#endif
+#endif
+
+#ifdef __FLOG_ACTIVE
+#define IF_FLOGGING(a) a
+#else
+#define IF_FLOGGING(a)
+#endif
+
+_LIT8(KDefaultLogFile, "obex");
+
+#ifdef __FLOG_ACTIVE
+#define LEAVEIFERRORL(a) VerboseLeaveIfErrorL(KLogComponent, __FILE__, __LINE__, a)
+#define PANIC(CAT, CODE) VerbosePanic(KLogComponent, __FILE__, __LINE__, CODE, (TText8*)#CODE, CAT)
+#define FLOG(a) CObexLog::Write(KDefaultLogFile, a);
+
+#define FTRACE(a) {a;}
+#define LOG(text) CObexLog::Write(KLogComponent, text);
+#define LOG1(text, a) CObexLog::WriteFormat(KLogComponent, text, a);
+#define LOG2(text, a, b) CObexLog::WriteFormat(KLogComponent, text, a, b);
+#define LOG3(text, a, b, c) CObexLog::WriteFormat(KLogComponent, text, a, b, c);
+#define LOGHEXDESC(desc) CObexLog::HexDump(KLogComponent, 0, 0, desc.Ptr() , desc.Length());
+#define LOGHEXRAW(data, len) CObexLog::HexDump(KLogComponent, 0, 0, data, len);
+#else
+#define LEAVEIFERRORL(a) static_cast<void>(User::LeaveIfError(a))
+#define PANIC(CAT, CODE) User::Panic(CAT, CODE)
+#define FLOG(a)
+#define FTRACE(a)
+#define LOG(text)
+#define LOG1(text, a)
+#define LOG2(text, a, b)
+#define LOG3(text, a, b, c)
+#define LOGHEXDESC(desc)
+#define LOGHEXRAW(data, len)
+#endif // __FLOG_ACTIVE
+
+#define FORCED_LOG_FUNC TFunctionLogger __instrument(KLogComponent, TPtrC8((TUint8*)__PRETTY_FUNCTION__), (TAny*)this);
+#define FORCED_LOG_STATIC_FUNC_ENTRY TFunctionLogger __instrument(KLogComponent, TPtrC8((TUint8*)__PRETTY_FUNCTION__), (TAny*)NULL);
+
+#if ( defined __FLOG_ACTIVE && defined __LOG_FUNCTIONS__ )
+#define LOG_LINE CObexLog::Write(KLogComponent, KNullDesC8());
+#define LOG_FUNC FORCED_LOG_FUNC
+#define LOG_STATIC_FUNC_ENTRY FORCED_LOG_STATIC_FUNC_ENTRY
+#else
+#define LOG_LINE
+#define LOG_FUNC
+#define LOG_STATIC_FUNC_ENTRY
+#endif
+
+
+
+NONSHARABLE_CLASS(CObexLog) : public CBase
+ {
+public:
+ IMPORT_C static TInt Connect();
+ IMPORT_C static void Close();
+
+ IMPORT_C static void Write(const TDesC8& aCmpt, const TDesC8& aText);
+ IMPORT_C static void WriteFormat(const TDesC8& aCmpt, TRefByValue<const TDesC8> aFmt, ...);
+ IMPORT_C static void WriteFormat(const TDesC8& aCmpt, TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
+ IMPORT_C static void Write(const TDesC8& aCmpt, const TDesC16& aText);
+ IMPORT_C static void WriteFormat(const TDesC8& aCmpt, TRefByValue<const TDesC16> aFmt, ...);
+ IMPORT_C static void WriteFormat(const TDesC8& aCmpt, TRefByValue<const TDesC16> aFmt, VA_LIST& aList);
+ IMPORT_C static void HexDump(const TDesC8& aCmpt, const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen);
+ };
+
+
+#ifndef NO_FPRINT
+inline void FPrint(const TRefByValue<const TDesC> IF_FLOGGING(aFmt), ...)
+ {
+#ifdef __FLOG_ACTIVE
+ VA_LIST list;
+ VA_START(list,aFmt);
+ CObexLog::WriteFormat(KDefaultLogFile, aFmt, list);
+#endif
+ }
+#endif
+
+
+#ifndef NO_FHEX_PTR
+inline void FHex(const TUint8* IF_FLOGGING(aPtr), TInt IF_FLOGGING(aLen))
+ {
+#ifdef __FLOG_ACTIVE
+ CObexLog::HexDump(KDefaultLogFile, 0, 0, aPtr, aLen);
+#endif
+ }
+#endif
+
+
+#ifndef NO_FHEX_DESC
+inline void FHex(const TDesC8& IF_FLOGGING(aDes))
+ {
+#ifdef __FLOG_ACTIVE
+ FHex(aDes.Ptr(), aDes.Length());
+#endif
+ }
+#endif
+
+
+IMPORT_C void VerboseLeaveIfErrorL(const TDesC8& aCpt,
+ char* aFile,
+ TInt aLine,
+ TInt aReason);
+
+IMPORT_C void VerbosePanic(const TDesC8& aCpt,
+ char* aFile,
+ TInt aLine,
+ TInt aPanicCode,
+ TText8* aPanicName,
+ const TDesC& aPanicCategory);
+
+NONSHARABLE_CLASS(TFunctionLogger)
+ {
+public:
+ IMPORT_C TFunctionLogger(const TDesC8& aCpt, const TDesC8& aString, TAny* aThis);
+ IMPORT_C ~TFunctionLogger();
+
+private:
+ TPtrC8 iCpt;
+ TPtrC8 iString;
+ };
+
+#endif // LOGGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/group/bld.inf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,24 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "../obextransport/group/BLD.INF"
+#include "../obex/group/BLD.INF"
+#include "../obexbttransport/group/BLD.INF"
+#include "../obexusbtransport/group/BLD.INF"
+
+
+PRJ_EXPORTS
+obexprotocol.iby /epoc32/rom/include/obexprotocol.iby
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/group/obex.history.xml Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<relnotes name="OBEX Protocol">
+ <purpose>
+ OBEX session protocol over IrDA, Bluetooth, and USB transports, supporting connections from simple beaming all the way to full-fledged synchronisation technologies such as SyncML and IrMC (note: Obex can support IrMC, but it is not actually supported in the OS at the moment).
+ </purpose>
+
+ <defect number="DEF141510" title="Missing distribution.policy.s60 files " revision="032">
+ Added source \sf\mw\remoteconn\obex\obexprotocol in obex.mrp file
+ </defect>
+
+ <defect number="PDEF139836" title=".esk and .cmi files do not have header" revision="031">
+ Added copyright headers
+ </defect>
+
+ <deliverystep number="1657" name="Remove IrDA" osproject="SymTB9.2" revision="001">
+ <preq number="2613" title="Remove IrDA"/>
+ </deliverystep>
+ <milestone project="GT0418" number="3.3"/>
+
+ <defect number="DEF133406" title="Obex def files changes for armv7 " revision="030">
+ Remove IMPORT_C from CObexServer::~CObexServer and the entry in mark bwins def file absent.
+ </defect>
+
+ <defect number="DEF132890" title="[ONB Coverity] CHECKED_RETURN error in TObex " revision="029">
+ Static analysis failures corrected.
+ </defect>
+
+ <defect number="DEF130710" title="Remove filename case check test code errors from OBEX" revision="028">
+ Static analysis failures corrected.
+ </defect>
+
+ <defect number="DEF130790" title="[Coverity]-MISSING_BREAK -obex/obextransport" revision="027">
+ Static analysis failures corrected.
+ </defect>
+
+ <defect number="DEF128204" title="errors in IM tagging in shortlink" revision="026">
+ Correct the IM tagging.
+ </defect>
+
+ <defect number="PDEF126953" title="It is often useful to call RFile::Flush() before a file is closed" revision="025">
+ Invoke RFile::Flush() when final file write is finished.
+ </defect>
+
+ <defect number="DEF126185" title="Extra member qualifications" revision="024">
+ 'CObex::' removed from member function CancelObexConnection declaration.
+ </defect>
+
+ <defect number="DEF124961" title="[Coverity]CHECKED_RETURN failure in TObexInternalHeader" revision="023">
+ If GetHVText returns an error, the number of bytes actually written by WriteOut is 0.
+ </defect>
+
+ <defect number="DEF124960" title="[Coverity]4 CHECKED_RETURN failures in CObexClient" revision="022">
+ Check returned value from InsertData and leave if not enough space to insert data.
+ </defect>
+
+ <defect number="DEF124958" title="[Coverity]FORWARD_NULL failure in CObexBaseObject" revision="021">
+ The "if is null" statements were not necessary. replaced with debug assertions.
+ </defect>
+
+ <defect number="DEF124957" title="[Coverity]FORWARD_NULL failure in CObexBufObject" revision="020">
+ Added two assertions to avoid calling the methods on an invalid pointer.
+ </defect>
+
+ <defect number="DEF124956" title="[Coverity] REVERSE_INULL failure in CObexServer" revision="019">
+ put some assertions to be sure that this pointer is not null (it must be valid)
+ </defect>
+
+ <defect number="DEF121787" title="Changes required to match fix made in Base USB Peripheral driver" revision="018">
+ Add indication that no control transfers are expected on either obex interface.
+ </defect>
+
+ <defect number="PDEF119945" title="Configuring L2CAP MTU for optimum performance " revision="017">
+ Changes to accomodate MTU size changes.
+ </defect>
+
+ <defect number="DEF119732" title="OBEX logger's LEAVEIFERRORL sometimes leaves if not error" revision="016">
+ OBEX logger's LEAVEIFERRORL did not leave from User::LeaveIfError if you pass it a positive value.
+ </defect>
+
+ <defect number="DEF117240" title="Correct LeaveScan error in emptyheaderstest.cpp" revision="015">
+ Changed methods names according to coding standard due to avoid LeaveScan error.
+ </defect>
+
+ <defect number="DEF117239" title="Correct LeaveScan error in IrOBEXUtil" revision="014">
+ Changed code to avoid LeaveScan reporting error.
+ </defect>
+
+ <defect number="PDEF114506" title="Klocwork issues in obex" revision="013">
+ Initialise max send/recv packet sizes to the maximum size of an IrDA packet before GetOpt is called.
+ </defect>
+
+ <defect number="PDEF113644" title="Obex needs to ignore malformed time Headers " revision="012">
+ Modified function CObexBaseObject::ParseNextReceivePacket so that, instead of interrupting the parsing and returning an error when there are problems with the TIME header, it ignores the header and continues parsing the packet.
+ </defect>
+
+ <defect number="PDEF112614" title="TObex panics if it gets a large name header when acting as FTP server" revision="011">
+ TObex will now truncate filename of an object that is PUT on the server if its complete path is too long to fit within the OS limit (256 chars).
+ </defect>
+
+ <defect number="PDEF112489" title="Misleading Obex error code" revision="010">
+ Rename error code to EUnexpectedChallengeResponse.
+ </defect>
+
+ <defect number="PDEF107489" title="Obex server error handling problem" revision="009">
+ ERespUnauthorized will be treated as a valid response to connect request, because this can be originated from obex packet access extension.
+ </defect>
+
+ <defect number="PDEF106896" title="TTG:Unexpected response to PUT/GET Requests with Auth'n Challenge" revision="008">
+ Alter Obex response to Put, Get and SetPath requests that contain an authentication challenge. These now respond with the "Unauthorized" opcode.
+ </defect>
+
+ <minorchange revision="007">
+ PDEF106501: Correctly set final bit flag on EOB header response for empty objects.
+ </minorchange>
+
+ <defect number="DEF101319" title="Filename case check failures in source build and test" revision="006">
+ Corrected filenames to enable building of Symbian OS in Linux
+ </defect>
+
+ <defect number="PDEF103383" title="?P903i? could not receive Contact data via Infrared" revision="005">
+ Workaround for interop with P903i and others whose servers return opcode success (instead of continue) in response to a Put request.
+ </defect>
+
+ <defect number="PDEF101514" title="TTG:OBEX server respond improper response instead of Bad Request(0xC0)" revision="004">
+ Upgrade the Obex server so that if an Abort command is received whilst an Obex Session his being Connected or when it is not Connected then, instead of bringing the underlying transport down, the Obex server replies with success.
+ </defect>
+
+ <defect number="PDEF101048" title="Renameobex test files testDef094745.*" revision="003">
+ Renamed test files and menu items in the manual test Tobex so that they are based on the functionality being tested rather than using the numerical code for the defect that they were produced for.
+ </defect>
+
+ <defect number="PDEF100899" title="TTG:<On receiving other than Other Response(OK(A0h), it cannot be disconnected >" revision="002">
+ Fix to Obex to bring transport down if clean disconnection fails.
+ </defect>
+
+ <defect number="PDEF100845" title="Fix for PDEF091783 causes authentication regression" revision="001">
+ Authentication loophole removed
+ </defect>
+ </relnotes>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/group/obex.mrp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,28 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+component obex
+source \sf\mw\remoteconn\obex\obexprotocol
+
+binary \sf\mw\remoteconn\obex\obexprotocol\group all
+exports \sf\mw\remoteconn\obex\obexprotocol\group
+notes_source \component_defs\release.src
+
+
+ipr E
+ipr T \sf\mw\remoteconn\obex\obexprotocol\obex\test
+ipr T \sf\mw\remoteconn\obex\obexprotocol\obextransport\test
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/group/obexprotocol.iby Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,83 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Obex
+// obexprotocol.iby
+//
+//
+
+#ifndef __OBEXPROTOCOL_IBY__
+#define __OBEXPROTOCOL_IBY__
+
+REM If __OBEX_DEBUG__ is defined pull in debug versions of the
+REM OBEX DLLs and transport controllers regardless of the ROM type
+#ifdef __OBEX_DEBUG__
+define OBEX_DIR UDEB
+#define OBEX_PLUGIN ECOM_PLUGIN_UDEB
+#else
+define OBEX_DIR BUILD_DIR
+#define OBEX_PLUGIN ECOM_PLUGIN
+#endif
+
+REM *** The following iby files are always included, whether obex is
+REM *** supported by the device or not.
+
+#include <ecom.iby>
+
+#if defined(_DEBUG) || defined (__OBEX_DEBUG__)
+#include <commsdebugutility.iby>
+#endif
+
+REM *** The following dlls are client side dlls. They are always included
+REM *** in the ROM, whether obex is supported by the device or not, so
+REM *** that client applications can link against them regardless.
+
+file=ABI_DIR\OBEX_DIR\obex.dll sys\bin\OBEX.dll
+REM Alias new obex.dll to also appear as irobex.dll to support legacy apps
+alias sys\bin\obex.dll sys\bin\irobex.dll
+
+file=ABI_DIR\OBEX_DIR\obexcommontransport.dll System\Libs\obexcommontransport.dll
+
+#ifdef SYMBIAN_INCLUDE_OBEX_EXTENSIONAPIS
+file=ABI_DIR\OBEX_DIR\obexextensionapis.dll sys\bin\obexextensionapis.dll
+#endif
+
+REM *** Now for things which should only be included if the device
+REM *** supports OBEX, to save ROM space...
+
+#ifdef SYMBIAN_EXCLUDE_OBEX
+REM Feature OBEX is not in this ROM
+#else
+
+
+REM *** Now for things which should only be included if the device
+REM *** supports USB, to save ROM space...
+
+#ifndef __USB
+REM OBEX USB transport is not included in this ROM as it depends on USB
+#else
+OBEX_PLUGIN(obexusbtransportcontroller.dll,1020de87.rsc)
+#endif
+
+REM *** Now for things which should only be included if the device
+REM *** supports bluetooth, to save ROM space...
+
+#ifndef __BT
+REM OBEX Bluetooth transport is not included in this ROM as it depends on BLUETOOTH
+#else
+OBEX_PLUGIN(obexbtrfcommtransportcontroller.dll,1020e043.rsc)
+#endif
+
+#endif // SYMBIAN_EXCLUDE_OBEX
+
+#endif // __OBEXPROTOCOL_IBY__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/bwins/IROBEX2U.DEF Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,149 @@
+EXPORTS
+ ??0TObexBufferingDetails@@QAE@AAVCBufBase@@@Z @ 1 NONAME ; TObexBufferingDetails::TObexBufferingDetails(class CBufBase &)
+ ??0TObexConnectInfo@@QAE@XZ @ 2 NONAME ; TObexConnectInfo::TObexConnectInfo(void)
+ ??0TObexFilenameBackedBuffer@@QAE@AAVCBufBase@@ABVTPtrC16@@W4TFileBuffering@CObexBufObject@@@Z @ 3 NONAME ; TObexFilenameBackedBuffer::TObexFilenameBackedBuffer(class CBufBase &, class TPtrC16 const &, enum CObexBufObject::TFileBuffering)
+ ??0TObexProtocolPolicy@@QAE@XZ @ 4 NONAME ; TObexProtocolPolicy::TObexProtocolPolicy(void)
+ ??0TObexPureFileBuffer@@QAE@ABVTPtrC16@@@Z @ 5 NONAME ; TObexPureFileBuffer::TObexPureFileBuffer(class TPtrC16 const &)
+ ??0TObexRFileBackedBuffer@@QAE@AAVCBufBase@@VRFile@@W4TFileBuffering@CObexBufObject@@@Z @ 6 NONAME ; TObexRFileBackedBuffer::TObexRFileBackedBuffer(class CBufBase &, class RFile, enum CObexBufObject::TFileBuffering)
+ ??0TSetPathInfo@CObex@@QAE@XZ @ 7 NONAME ; CObex::TSetPathInfo::TSetPathInfo(void)
+ ??1CObexBufObject@@UAE@XZ @ 8 NONAME ; CObexBufObject::~CObexBufObject(void)
+ ??1CObexClient@@UAE@XZ @ 9 NONAME ; CObexClient::~CObexClient(void)
+ ??1CObexFileObject@@UAE@XZ @ 10 NONAME ; CObexFileObject::~CObexFileObject(void)
+ ??1CObexServer@@UAE@XZ @ 11 NONAME ABSENT ; CObexServer::~CObexServer(void)
+ ?Abort@CObexClient@@QAEXXZ @ 12 NONAME ; void CObexClient::Abort(void)
+ ?AddHeader@CObexHeaderSet@@QAEHPAVCObexHeader@@@Z @ 13 NONAME ; int CObexHeaderSet::AddHeader(class CObexHeader *)
+ ?AddHeaderL@CObexBaseObject@@QAEXAAVCObexHeader@@@Z @ 14 NONAME ; void CObexBaseObject::AddHeaderL(class CObexHeader &)
+ ?AddHttpL@CObexBaseObject@@QAEXABVTDesC8@@@Z @ 15 NONAME ; void CObexBaseObject::AddHttpL(class TDesC8 const &)
+ ?AppParam@CObexBaseObject@@QBEABVTDesC8@@XZ @ 16 NONAME ; class TDesC8 const & CObexBaseObject::AppParam(void) const
+ ?AsByte@CObexHeader@@QBEEXZ @ 17 NONAME ; unsigned char CObexHeader::AsByte(void) const
+ ?AsByteSeq@CObexHeader@@QBEABVTDesC8@@XZ @ 18 NONAME ; class TDesC8 const & CObexHeader::AsByteSeq(void) const
+ ?AsFourByte@CObexHeader@@QBEKXZ @ 19 NONAME ; unsigned long CObexHeader::AsFourByte(void) const
+ ?AsUnicode@CObexHeader@@QBEABVTDesC16@@XZ @ 20 NONAME ; class TDesC16 const & CObexHeader::AsUnicode(void) const
+ ?Attributes@CObexHeader@@QBEGXZ @ 21 NONAME ; unsigned short CObexHeader::Attributes(void) const
+ ?BytesReceived@CObexBaseObject@@QAEHXZ @ 22 NONAME ; int CObexBaseObject::BytesReceived(void)
+ ?BytesSent@CObexBaseObject@@QAEHXZ @ 23 NONAME ; int CObexBaseObject::BytesSent(void)
+ ?Connect@CObexClient@@QAEXAAVCObexBaseObject@@AAVTRequestStatus@@@Z @ 24 NONAME ; void CObexClient::Connect(class CObexBaseObject &, class TRequestStatus &)
+ ?Connect@CObexClient@@QAEXAAVTRequestStatus@@@Z @ 25 NONAME ; void CObexClient::Connect(class TRequestStatus &)
+ ?ConnectL@CObexClient@@QAEXAAVCObexBaseObject@@ABVTDesC16@@AAVTRequestStatus@@@Z @ 26 NONAME ; void CObexClient::ConnectL(class CObexBaseObject &, class TDesC16 const &, class TRequestStatus &)
+ ?ConnectL@CObexClient@@QAEXABVTDesC16@@AAVTRequestStatus@@@Z @ 27 NONAME ; void CObexClient::ConnectL(class TDesC16 const &, class TRequestStatus &)
+ ?ConnectState@CObex@@IBE?AW4TConnectState@1@XZ @ 28 NONAME ; enum CObex::TConnectState CObex::ConnectState(void) const
+ ?CopyL@CObexHeader@@QBEPAV1@XZ @ 29 NONAME ; class CObexHeader * CObexHeader::CopyL(void) const
+ ?CopyL@CObexHeaderSet@@QAEPAV1@AAVMObexHeaderCheck@@@Z @ 30 NONAME ; class CObexHeaderSet * CObexHeaderSet::CopyL(class MObexHeaderCheck &)
+ ?CopyL@CObexHeaderSet@@QAEPAV1@XZ @ 31 NONAME ; class CObexHeaderSet * CObexHeaderSet::CopyL(void)
+ ?Count@CObexHeaderSet@@QBEHXZ @ 32 NONAME ; int CObexHeaderSet::Count(void) const
+ ?CurrentOperation@CObexServer@@QBE?AW4TOperation@CObex@@XZ @ 33 NONAME ; enum CObex::TOperation CObexServer::CurrentOperation(void) const
+ ?DataBuf@CObexBufObject@@QAEPAVCBufBase@@XZ @ 34 NONAME ; class CBufBase * CObexBufObject::DataBuf(void)
+ ?DeleteCurrentHeader@CObexHeaderSet@@QAEXXZ @ 35 NONAME ; void CObexHeaderSet::DeleteCurrentHeader(void)
+ ?DeleteMasked@CObexHeaderSet@@QAEXXZ @ 36 NONAME ; void CObexHeaderSet::DeleteMasked(void)
+ ?Description@CObexBaseObject@@QAEABVTDesC16@@XZ @ 37 NONAME ; class TDesC16 const & CObexBaseObject::Description(void)
+ ?Disconnect@CObexClient@@QAEXAAVTRequestStatus@@@Z @ 38 NONAME ; void CObexClient::Disconnect(class TRequestStatus &)
+ ?EncodedSize@CObexHeader@@QBEHXZ @ 39 NONAME ; int CObexHeader::EncodedSize(void) const
+ ?Find@CObexHeaderSet@@QBEHEAAVCObexHeader@@@Z @ 40 NONAME ; int CObexHeaderSet::Find(unsigned char, class CObexHeader &) const
+ ?First@CObexHeaderSet@@QBEXXZ @ 41 NONAME ; void CObexHeaderSet::First(void) const
+ ?Get@CObexClient@@QAEXAAVCObexBaseObject@@AAVTRequestStatus@@@Z @ 42 NONAME ; void CObexClient::Get(class CObexBaseObject &, class TRequestStatus &)
+ ?GetPutFinalResponseHeaders@CObexClient@@QAEABVCObexHeaderSet@@XZ @ 43 NONAME ; class CObexHeaderSet const & CObexClient::GetPutFinalResponseHeaders(void)
+ ?HI@CObexHeader@@QBEEXZ @ 44 NONAME ; unsigned char CObexHeader::HI(void) const
+ ?HeaderMask@CObexBaseObject@@QAEGXZ @ 45 NONAME ; unsigned short CObexBaseObject::HeaderMask(void)
+ ?HeaderSet@CObexBaseObject@@QAEAAVCObexHeaderSet@@XZ @ 46 NONAME ; class CObexHeaderSet & CObexBaseObject::HeaderSet(void)
+ ?HeaderSet@CObexBaseObject@@QBEABVCObexHeaderSet@@XZ @ 47 NONAME ; class CObexHeaderSet const & CObexBaseObject::HeaderSet(void) const
+ ?Http@CObexBaseObject@@QBEPBV?$RPointerArray@VHBufC8@@@@XZ @ 48 NONAME ; class RPointerArray<class HBufC8> const * CObexBaseObject::Http(void) const
+ ?InitFromFileL@CObexFileObject@@QAEXABVTDesC16@@@Z @ 49 NONAME ; void CObexFileObject::InitFromFileL(class TDesC16 const &)
+ ?Interested@TObexMatchHeader@@UAEHE@Z @ 50 NONAME ; int TObexMatchHeader::Interested(unsigned char)
+ ?Interested@TObexMatchHeaderType@@UAEHE@Z @ 51 NONAME ; int TObexMatchHeaderType::Interested(unsigned char)
+ ?IsConnected@CObex@@QBEHXZ @ 52 NONAME ; int CObex::IsConnected(void) const
+ ?IsStarted@CObexServer@@QAEHXZ @ 53 NONAME ; int CObexServer::IsStarted(void)
+ ?IsStrictPeer@CObex@@QBEHXZ @ 54 NONAME ; int CObex::IsStrictPeer(void) const
+ ?Length@CObexBaseObject@@QAEKXZ @ 55 NONAME ; unsigned long CObexBaseObject::Length(void)
+ ?LocalInfo@CObex@@QBEABVTObexConnectInfo@@XZ @ 56 NONAME ; class TObexConnectInfo const & CObex::LocalInfo(void) const
+ ?Name@CObexBaseObject@@QAEABVTDesC16@@XZ @ 57 NONAME ; class TDesC16 const & CObexBaseObject::Name(void)
+ ?NewL@CObexBufObject@@SAPAV1@PAVCBufBase@@@Z @ 58 NONAME ; class CObexBufObject * CObexBufObject::NewL(class CBufBase *)
+ ?NewL@CObexClient@@SAPAV1@AAVTObexProtocolInfo@@@Z @ 59 NONAME ; class CObexClient * CObexClient::NewL(class TObexProtocolInfo &)
+ ?NewL@CObexClient@@SAPAV1@AAVTObexProtocolInfo@@AAVTObexProtocolPolicy@@@Z @ 60 NONAME ; class CObexClient * CObexClient::NewL(class TObexProtocolInfo &, class TObexProtocolPolicy &)
+ ?NewL@CObexFileObject@@SAPAV1@ABVTDesC16@@@Z @ 61 NONAME ; class CObexFileObject * CObexFileObject::NewL(class TDesC16 const &)
+ ?NewL@CObexHeader@@SAPAV1@XZ @ 62 NONAME ; class CObexHeader * CObexHeader::NewL(void)
+ ?NewL@CObexHeaderSet@@SAPAV1@XZ @ 63 NONAME ; class CObexHeaderSet * CObexHeaderSet::NewL(void)
+ ?NewL@CObexNullObject@@SAPAV1@XZ @ 64 NONAME ; class CObexNullObject * CObexNullObject::NewL(void)
+ ?NewL@CObexServer@@SAPAV1@AAVTObexProtocolInfo@@@Z @ 65 NONAME ; class CObexServer * CObexServer::NewL(class TObexProtocolInfo &)
+ ?NewL@CObexServer@@SAPAV1@AAVTObexProtocolInfo@@AAVTObexProtocolPolicy@@@Z @ 66 NONAME ; class CObexServer * CObexServer::NewL(class TObexProtocolInfo &, class TObexProtocolPolicy &)
+ ?Next@CObexHeaderSet@@QBEHH@Z @ 67 NONAME ; int CObexHeaderSet::Next(int) const
+ ?Parent@TSetPathInfo@CObex@@QBEHXZ @ 68 NONAME ; int CObex::TSetPathInfo::Parent(void) const
+ ?Put@CObexClient@@QAEXAAVCObexBaseObject@@AAVTRequestStatus@@@Z @ 69 NONAME ; void CObexClient::Put(class CObexBaseObject &, class TRequestStatus &)
+ ?ReceiveMtu@TObexProtocolPolicy@@QBEGXZ @ 70 NONAME ; unsigned short TObexProtocolPolicy::ReceiveMtu(void) const
+ ?RemoteAddr@CObex@@QAEXAAVTSockAddr@@@Z @ 71 NONAME ; void CObex::RemoteAddr(class TSockAddr &)
+ ?RemoteInfo@CObex@@QBEABVTObexConnectInfo@@XZ @ 72 NONAME ; class TObexConnectInfo const & CObex::RemoteInfo(void) const
+ ?Reset@CObexBaseObject@@QAEXXZ @ 73 NONAME ; void CObexBaseObject::Reset(void)
+ ?Reset@CObexHeader@@QAEXXZ @ 74 NONAME ; void CObexHeader::Reset(void)
+ ?Reset@MObexHeaderCheck@@UAEXXZ @ 75 NONAME ; void MObexHeaderCheck::Reset(void)
+ ?ResetChallenge@CObexServer@@QAEXXZ @ 76 NONAME ; void CObexServer::ResetChallenge(void)
+ ?ResetContents@CObexHeader@@QAEXXZ @ 77 NONAME ; void CObexHeader::ResetContents(void)
+ ?Set@CObexHeader@@QAEXPAV1@@Z @ 78 NONAME ; void CObexHeader::Set(class CObexHeader *)
+ ?SetAppParamL@CObexBaseObject@@QAEXABVTDesC8@@@Z @ 79 NONAME ; void CObexBaseObject::SetAppParamL(class TDesC8 const &)
+ ?SetAttributes@CObexHeader@@QAEXG@Z @ 80 NONAME ; void CObexHeader::SetAttributes(unsigned short)
+ ?SetByte@CObexHeader@@QAEXEE@Z @ 81 NONAME ; void CObexHeader::SetByte(unsigned char, unsigned char)
+ ?SetByteSeqL@CObexHeader@@QAEXEABVTDesC8@@@Z @ 82 NONAME ; void CObexHeader::SetByteSeqL(unsigned char, class TDesC8 const &)
+ ?SetCallBack@CObex@@QAEXAAVMObexAuthChallengeHandler@@@Z @ 83 NONAME ; void CObex::SetCallBack(class MObexAuthChallengeHandler &)
+ ?SetChallengeL@CObexServer@@QAEXABVTDesC16@@@Z @ 84 NONAME ; void CObexServer::SetChallengeL(class TDesC16 const &)
+ ?SetDataBufL@CObexBufObject@@QAEXAAVTObexBufferingDetails@@@Z @ 85 NONAME ; void CObexBufObject::SetDataBufL(class TObexBufferingDetails &)
+ ?SetDataBufL@CObexBufObject@@QAEXABVTPtrC16@@@Z @ 86 NONAME ; void CObexBufObject::SetDataBufL(class TPtrC16 const &)
+ ?SetDataBufL@CObexBufObject@@QAEXABVTPtrC16@@AAVCBufBase@@W4TFileBuffering@1@@Z @ 87 NONAME ; void CObexBufObject::SetDataBufL(class TPtrC16 const &, class CBufBase &, enum CObexBufObject::TFileBuffering)
+ ?SetDataBufL@CObexBufObject@@QAEXABVTPtrC16@@PAVCBufBase@@@Z @ 88 NONAME ; void CObexBufObject::SetDataBufL(class TPtrC16 const &, class CBufBase *)
+ ?SetDataBufL@CObexBufObject@@QAEXPAVCBufBase@@@Z @ 89 NONAME ; void CObexBufObject::SetDataBufL(class CBufBase *)
+ ?SetDescriptionL@CObexBaseObject@@QAEXABVTDesC16@@@Z @ 90 NONAME ; void CObexBaseObject::SetDescriptionL(class TDesC16 const &)
+ ?SetFourByte@CObexHeader@@QAEXEK@Z @ 91 NONAME ; void CObexHeader::SetFourByte(unsigned char, unsigned long)
+ ?SetHeader@TObexMatchHeader@@QAEXE@Z @ 92 NONAME ; void TObexMatchHeader::SetHeader(unsigned char)
+ ?SetHeaderMask@CObexBaseObject@@QAEXG@Z @ 93 NONAME ; void CObexBaseObject::SetHeaderMask(unsigned short)
+ ?SetLengthL@CObexBaseObject@@QAEXK@Z @ 94 NONAME ; void CObexBaseObject::SetLengthL(unsigned long)
+ ?SetLocalWho@CObex@@QAEHABVTDesC8@@@Z @ 95 NONAME ; int CObex::SetLocalWho(class TDesC8 const &)
+ ?SetMask@CObexHeaderSet@@QAEXPAVMObexHeaderCheck@@@Z @ 96 NONAME ; void CObexHeaderSet::SetMask(class MObexHeaderCheck *)
+ ?SetNameL@CObexBaseObject@@QAEXABVTDesC16@@@Z @ 97 NONAME ; void CObexBaseObject::SetNameL(class TDesC16 const &)
+ ?SetPath@CObexClient@@QAEXAAVTSetPathInfo@CObex@@AAVTRequestStatus@@@Z @ 98 NONAME ; void CObexClient::SetPath(class CObex::TSetPathInfo &, class TRequestStatus &)
+ ?SetPutFinalResponseHeaders@CObexServer@@QAEHPAVCObexHeaderSet@@@Z @ 99 NONAME ; int CObexServer::SetPutFinalResponseHeaders(class CObexHeaderSet *)
+ ?SetReceiveMtu@TObexProtocolPolicy@@QAEHG@Z @ 100 NONAME ; int TObexProtocolPolicy::SetReceiveMtu(unsigned short)
+ ?SetTargetChecking@CObexServer@@QAEXW4TTargetChecking@1@@Z @ 101 NONAME ; void CObexServer::SetTargetChecking(enum CObexServer::TTargetChecking)
+ ?SetTargetL@CObexBaseObject@@QAEXABVTDesC8@@@Z @ 102 NONAME ; void CObexBaseObject::SetTargetL(class TDesC8 const &)
+ ?SetTimeL@CObexBaseObject@@QAEXVTTime@@@Z @ 103 NONAME ; void CObexBaseObject::SetTimeL(class TTime)
+ ?SetTransmitMtu@TObexProtocolPolicy@@QAEHG@Z @ 104 NONAME ; int TObexProtocolPolicy::SetTransmitMtu(unsigned short)
+ ?SetType@TObexMatchHeaderType@@QAEXW4THeaderType@CObexHeader@@@Z @ 105 NONAME ; void TObexMatchHeaderType::SetType(enum CObexHeader::THeaderType)
+ ?SetTypeL@CObexBaseObject@@QAEXABVTDesC8@@@Z @ 106 NONAME ; void CObexBaseObject::SetTypeL(class TDesC8 const &)
+ ?SetUnicodeL@CObexHeader@@QAEXEABVTDesC16@@@Z @ 107 NONAME ; void CObexHeader::SetUnicodeL(unsigned char, class TDesC16 const &)
+ ?Start@CObexServer@@QAEHPAVMObexServerNotify@@@Z @ 108 NONAME ; int CObexServer::Start(class MObexServerNotify *)
+ ?Stop@CObexServer@@QAEXXZ @ 109 NONAME ; void CObexServer::Stop(void)
+ ?Target@CObexBaseObject@@QAEABVTDesC8@@XZ @ 110 NONAME ; class TDesC8 const & CObexBaseObject::Target(void)
+ ?This@CObexHeaderSet@@QBEHPAVCObexHeader@@@Z @ 111 NONAME ; int CObexHeaderSet::This(class CObexHeader *) const
+ ?Time@CObexBaseObject@@QAE?BVTTime@@XZ @ 112 NONAME ; class TTime const CObexBaseObject::Time(void)
+ ?TransmitMtu@TObexProtocolPolicy@@QBEGXZ @ 113 NONAME ; unsigned short TObexProtocolPolicy::TransmitMtu(void) const
+ ?Type@CObexBaseObject@@QAEABVTDesC8@@XZ @ 114 NONAME ; class TDesC8 const & CObexBaseObject::Type(void)
+ ?Type@CObexHeader@@QBE?AW4THeaderType@1@XZ @ 115 NONAME ; enum CObexHeader::THeaderType CObexHeader::Type(void) const
+ ?UserPasswordL@CObexClient@@UAEXABVTDesC16@@@Z @ 116 NONAME ; void CObexClient::UserPasswordL(class TDesC16 const &)
+ ?UserPasswordL@CObexServer@@UAEXABVTDesC16@@@Z @ 117 NONAME ; void CObexServer::UserPasswordL(class TDesC16 const &)
+ ?ValidHeaders@CObexBaseObject@@QAEGXZ @ 118 NONAME ; unsigned short CObexBaseObject::ValidHeaders(void)
+ ?Version@TObexProtocolPolicy@@QBEGXZ @ 119 NONAME ; unsigned short TObexProtocolPolicy::Version(void) const
+ ?VersionMajor@TObexConnectInfo@@QBEEXZ @ 120 NONAME ; unsigned char TObexConnectInfo::VersionMajor(void) const
+ ?VersionMinor@TObexConnectInfo@@QBEEXZ @ 121 NONAME ; unsigned char TObexConnectInfo::VersionMinor(void) const
+ ?WriteToFile@CObexBufObject@@QAEHABVTPtrC16@@@Z @ 122 NONAME ; int CObexBufObject::WriteToFile(class TPtrC16 const &)
+ ?MOACH_ExtensionInterfaceL@MObexAuthChallengeHandler@@UAEXVTUid@@AAPAX@Z @ 123 NONAME ; void MObexAuthChallengeHandler::MOACH_ExtensionInterfaceL(class TUid, void * &)
+ ?MOHC_ExtensionInterfaceL@MObexHeaderCheck@@UAEXVTUid@@AAPAX@Z @ 124 NONAME ; void MObexHeaderCheck::MOHC_ExtensionInterfaceL(class TUid, void * &)
+ ?MOSN_ExtensionInterfaceL@MObexServerNotify@@UAEXVTUid@@AAPAX@Z @ 125 NONAME ; void MObexServerNotify::MOSN_ExtensionInterfaceL(class TUid, void * &)
+ ?NewL@CObexFileObject@@SAPAV1@XZ @ 126 NONAME ; class CObexFileObject * CObexFileObject::NewL(void)
+ ?Next@CObexHeaderSet@@QBEHXZ @ 127 NONAME ; int CObexHeaderSet::Next(void) const
+ ?NewL@CObexClient@@SAPAV1@AAVTObexTransportInfo@@@Z @ 128 NONAME ; class CObexClient * CObexClient::NewL(class TObexTransportInfo &)
+ ?NewL@CObexServer@@SAPAV1@AAVTObexTransportInfo@@@Z @ 129 NONAME ; class CObexServer * CObexServer::NewL(class TObexTransportInfo &)
+ ?SetFinalPacketObserver@CObexClient@@QAEXPAVMObexFinalPacketObserver@@@Z @ 130 NONAME ; void CObexClient::SetFinalPacketObserver(class MObexFinalPacketObserver *)
+ ?Start@CObexServer@@QAEHPAVMObexServerNotifyAsync@@@Z @ 131 NONAME ; int CObexServer::Start(class MObexServerNotifyAsync *)
+ ?MOSNA_ExtensionInterfaceL@MObexServerNotifyAsync@@UAEXVTUid@@AAPAX@Z @ 132 NONAME ; void MObexServerNotifyAsync::MOSNA_ExtensionInterfaceL(class TUid, void * &)
+ ?RequestIndicationCallback@CObexServer@@QAEHPAVCObexBaseObject@@@Z @ 133 NONAME ; int CObexServer::RequestIndicationCallback(class CObexBaseObject *)
+ ?RequestCompleteIndicationCallback@CObexServer@@QAEHH@Z @ 134 NONAME ; int CObexServer::RequestCompleteIndicationCallback(int)
+ ?RequestCompleteIndicationCallback@CObexServer@@QAEHW4TObexResponse@@@Z @ 135 NONAME ; int CObexServer::RequestCompleteIndicationCallback(enum TObexResponse)
+ ?RequestIndicationCallbackWithError@CObexServer@@QAEHH@Z @ 136 NONAME ; int CObexServer::RequestIndicationCallbackWithError(int)
+ ?RequestIndicationCallbackWithError@CObexServer@@QAEHW4TObexResponse@@@Z @ 137 NONAME ; int CObexServer::RequestIndicationCallbackWithError(enum TObexResponse)
+ ?IsAuthenticating@CObex@@QBEHXZ @ 138 NONAME ; int CObex::IsAuthenticating(void) const
+ ?LastServerResponseCode@CObexClient@@QBE?AW4TObexResponse@@XZ @ 139 NONAME ; enum TObexResponse CObexClient::LastServerResponseCode(void) const
+ ?ExtensionInterface@CObexClient@@QAEPAXVTUid@@@Z @ 140 NONAME ; void * CObexClient::ExtensionInterface(class TUid)
+ ?ExtensionInterfaceL@CObexServer@@QAEPAXVTUid@@@Z @ 141 NONAME ; void * CObexServer::ExtensionInterfaceL(class TUid)
+ ?PacketHeaders@CObexServer@@QAEHAAPAVCObexHeaderSet@@@Z @ 142 NONAME ; int CObexServer::PacketHeaders(class CObexHeaderSet * &)
+ ?PacketHeaders@CObexServer@@QAEHAAPAVCObexHeaderSet@@AAVMObexHeaderCheck@@@Z @ 143 NONAME ; int CObexServer::PacketHeaders(class CObexHeaderSet * &, class MObexHeaderCheck &)
+ ?SetCommandTimeOut@CObexClient@@QAEXVTTimeIntervalMicroSeconds32@@@Z @ 144 NONAME ; void CObexClient::SetCommandTimeOut(class TTimeIntervalMicroSeconds32)
+ ?SuppressAuthenticationHeaderElements@CObex@@QAEXW4TObexSuppressedAuthElements@1@@Z @ 145 NONAME ; void CObex::SuppressAuthenticationHeaderElements(enum CObex::TObexSuppressedAuthElements)
+ ?TransportInfo@CObexServer@@QBEPBVTObexTransportInfo@@XZ @ 146 NONAME ; class TObexTransportInfo const * CObexServer::TransportInfo(void) const
+ ?SetReadActivityObserver@CObexServer@@QAEXPAVMObexReadActivityObserver@@@Z @ 147 NONAME ; void CObexServer::SetReadActivityObserver(class MObexReadActivityObserver *)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/eabi/irobex2U.def Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,169 @@
+EXPORTS
+ _ZN11CObexClient10DisconnectER14TRequestStatus @ 1 NONAME
+ _ZN11CObexClient13UserPasswordLERK7TDesC16 @ 2 NONAME
+ _ZN11CObexClient26GetPutFinalResponseHeadersEv @ 3 NONAME
+ _ZN11CObexClient3GetER15CObexBaseObjectR14TRequestStatus @ 4 NONAME
+ _ZN11CObexClient3PutER15CObexBaseObjectR14TRequestStatus @ 5 NONAME
+ _ZN11CObexClient4NewLER17TObexProtocolInfo @ 6 NONAME
+ _ZN11CObexClient4NewLER17TObexProtocolInfoR19TObexProtocolPolicy @ 7 NONAME
+ _ZN11CObexClient5AbortEv @ 8 NONAME
+ _ZN11CObexClient7ConnectER14TRequestStatus @ 9 NONAME
+ _ZN11CObexClient7ConnectER15CObexBaseObjectR14TRequestStatus @ 10 NONAME
+ _ZN11CObexClient7SetPathERN5CObex12TSetPathInfoER14TRequestStatus @ 11 NONAME
+ _ZN11CObexClient8ConnectLER15CObexBaseObjectRK7TDesC16R14TRequestStatus @ 12 NONAME
+ _ZN11CObexClient8ConnectLERK7TDesC16R14TRequestStatus @ 13 NONAME
+ _ZN11CObexClientD0Ev @ 14 NONAME
+ _ZN11CObexClientD1Ev @ 15 NONAME
+ _ZN11CObexClientD2Ev @ 16 NONAME
+ _ZN11CObexHeader11SetByteSeqLEhRK6TDesC8 @ 17 NONAME
+ _ZN11CObexHeader11SetFourByteEhm @ 18 NONAME
+ _ZN11CObexHeader11SetUnicodeLEhRK7TDesC16 @ 19 NONAME
+ _ZN11CObexHeader13ResetContentsEv @ 20 NONAME
+ _ZN11CObexHeader13SetAttributesEt @ 21 NONAME
+ _ZN11CObexHeader3SetEPS_ @ 22 NONAME
+ _ZN11CObexHeader4NewLEv @ 23 NONAME
+ _ZN11CObexHeader5ResetEv @ 24 NONAME
+ _ZN11CObexHeader7SetByteEhh @ 25 NONAME
+ _ZN11CObexServer13SetChallengeLERK7TDesC16 @ 26 NONAME
+ _ZN11CObexServer13UserPasswordLERK7TDesC16 @ 27 NONAME
+ _ZN11CObexServer14ResetChallengeEv @ 28 NONAME
+ _ZN11CObexServer17SetTargetCheckingENS_15TTargetCheckingE @ 29 NONAME
+ _ZN11CObexServer26SetPutFinalResponseHeadersEP14CObexHeaderSet @ 30 NONAME
+ _ZN11CObexServer4NewLER17TObexProtocolInfo @ 31 NONAME
+ _ZN11CObexServer4NewLER17TObexProtocolInfoR19TObexProtocolPolicy @ 32 NONAME
+ _ZN11CObexServer4StopEv @ 33 NONAME
+ _ZN11CObexServer5StartEP17MObexServerNotify @ 34 NONAME
+ _ZN11CObexServer9IsStartedEv @ 35 NONAME
+ _ZN14CObexBufObject11SetDataBufLEP8CBufBase @ 36 NONAME
+ _ZN14CObexBufObject11SetDataBufLER21TObexBufferingDetails @ 37 NONAME
+ _ZN14CObexBufObject11SetDataBufLERK7TPtrC16 @ 38 NONAME
+ _ZN14CObexBufObject11SetDataBufLERK7TPtrC16P8CBufBase @ 39 NONAME
+ _ZN14CObexBufObject11SetDataBufLERK7TPtrC16R8CBufBaseNS_14TFileBufferingE @ 40 NONAME
+ _ZN14CObexBufObject11WriteToFileERK7TPtrC16 @ 41 NONAME
+ _ZN14CObexBufObject4NewLEP8CBufBase @ 42 NONAME
+ _ZN14CObexBufObject7DataBufEv @ 43 NONAME
+ _ZN14CObexBufObjectD0Ev @ 44 NONAME
+ _ZN14CObexBufObjectD1Ev @ 45 NONAME
+ _ZN14CObexBufObjectD2Ev @ 46 NONAME
+ _ZN14CObexHeaderSet12DeleteMaskedEv @ 47 NONAME
+ _ZN14CObexHeaderSet19DeleteCurrentHeaderEv @ 48 NONAME
+ _ZN14CObexHeaderSet4NewLEv @ 49 NONAME
+ _ZN14CObexHeaderSet5CopyLER16MObexHeaderCheck @ 50 NONAME
+ _ZN14CObexHeaderSet5CopyLEv @ 51 NONAME
+ _ZN14CObexHeaderSet7SetMaskEP16MObexHeaderCheck @ 52 NONAME
+ _ZN14CObexHeaderSet9AddHeaderEP11CObexHeader @ 53 NONAME
+ _ZN15CObexBaseObject10AddHeaderLER11CObexHeader @ 54 NONAME
+ _ZN15CObexBaseObject10HeaderMaskEv @ 55 NONAME
+ _ZN15CObexBaseObject10SetLengthLEm @ 56 NONAME
+ _ZN15CObexBaseObject10SetTargetLERK6TDesC8 @ 57 NONAME
+ _ZN15CObexBaseObject11DescriptionEv @ 58 NONAME
+ _ZN15CObexBaseObject12SetAppParamLERK6TDesC8 @ 59 NONAME
+ _ZN15CObexBaseObject12ValidHeadersEv @ 60 NONAME
+ _ZN15CObexBaseObject13BytesReceivedEv @ 61 NONAME
+ _ZN15CObexBaseObject13SetHeaderMaskEt @ 62 NONAME
+ _ZN15CObexBaseObject15SetDescriptionLERK7TDesC16 @ 63 NONAME
+ _ZN15CObexBaseObject4NameEv @ 64 NONAME
+ _ZN15CObexBaseObject4TimeEv @ 65 NONAME
+ _ZN15CObexBaseObject4TypeEv @ 66 NONAME
+ _ZN15CObexBaseObject5ResetEv @ 67 NONAME
+ _ZN15CObexBaseObject6LengthEv @ 68 NONAME
+ _ZN15CObexBaseObject6TargetEv @ 69 NONAME
+ _ZN15CObexBaseObject8AddHttpLERK6TDesC8 @ 70 NONAME
+ _ZN15CObexBaseObject8SetNameLERK7TDesC16 @ 71 NONAME
+ _ZN15CObexBaseObject8SetTimeLE5TTime @ 72 NONAME
+ _ZN15CObexBaseObject8SetTypeLERK6TDesC8 @ 73 NONAME
+ _ZN15CObexBaseObject9BytesSentEv @ 74 NONAME
+ _ZN15CObexBaseObject9HeaderSetEv @ 75 NONAME
+ _ZN15CObexFileObject13InitFromFileLERK7TDesC16 @ 76 NONAME
+ _ZN15CObexFileObject4NewLERK7TDesC16 @ 77 NONAME
+ _ZN15CObexFileObject4NewLEv @ 78 NONAME
+ _ZN15CObexFileObjectD0Ev @ 79 NONAME
+ _ZN15CObexFileObjectD1Ev @ 80 NONAME
+ _ZN15CObexFileObjectD2Ev @ 81 NONAME
+ _ZN15CObexNullObject4NewLEv @ 82 NONAME
+ _ZN16MObexHeaderCheck24MOHC_ExtensionInterfaceLE4TUidRPv @ 83 NONAME
+ _ZN16MObexHeaderCheck5ResetEv @ 84 NONAME
+ _ZN16TObexConnectInfoC1Ev @ 85 NONAME
+ _ZN16TObexConnectInfoC2Ev @ 86 NONAME
+ _ZN16TObexMatchHeader10InterestedEh @ 87 NONAME
+ _ZN16TObexMatchHeader9SetHeaderEh @ 88 NONAME
+ _ZN17MObexServerNotify24MOSN_ExtensionInterfaceLE4TUidRPv @ 89 NONAME
+ _ZN19TObexProtocolPolicy13SetReceiveMtuEt @ 90 NONAME
+ _ZN19TObexProtocolPolicy14SetTransmitMtuEt @ 91 NONAME
+ _ZN19TObexProtocolPolicyC1Ev @ 92 NONAME
+ _ZN19TObexProtocolPolicyC2Ev @ 93 NONAME
+ _ZN19TObexPureFileBufferC1ERK7TPtrC16 @ 94 NONAME
+ _ZN19TObexPureFileBufferC2ERK7TPtrC16 @ 95 NONAME
+ _ZN20TObexMatchHeaderType10InterestedEh @ 96 NONAME
+ _ZN20TObexMatchHeaderType7SetTypeEN11CObexHeader11THeaderTypeE @ 97 NONAME
+ _ZN21TObexBufferingDetailsC1ER8CBufBase @ 98 NONAME
+ _ZN21TObexBufferingDetailsC2ER8CBufBase @ 99 NONAME
+ _ZN22TObexRFileBackedBufferC1ER8CBufBase5RFileN14CObexBufObject14TFileBufferingE @ 100 NONAME
+ _ZN22TObexRFileBackedBufferC2ER8CBufBase5RFileN14CObexBufObject14TFileBufferingE @ 101 NONAME
+ _ZN25MObexAuthChallengeHandler25MOACH_ExtensionInterfaceLE4TUidRPv @ 102 NONAME
+ _ZN25TObexFilenameBackedBufferC1ER8CBufBaseRK7TPtrC16N14CObexBufObject14TFileBufferingE @ 103 NONAME
+ _ZN25TObexFilenameBackedBufferC2ER8CBufBaseRK7TPtrC16N14CObexBufObject14TFileBufferingE @ 104 NONAME
+ _ZN5CObex10RemoteAddrER9TSockAddr @ 105 NONAME
+ _ZN5CObex11SetCallBackER25MObexAuthChallengeHandler @ 106 NONAME
+ _ZN5CObex11SetLocalWhoERK6TDesC8 @ 107 NONAME
+ _ZN5CObex12TSetPathInfoC1Ev @ 108 NONAME
+ _ZN5CObex12TSetPathInfoC2Ev @ 109 NONAME
+ _ZNK11CObexHeader10AsFourByteEv @ 110 NONAME
+ _ZNK11CObexHeader10AttributesEv @ 111 NONAME
+ _ZNK11CObexHeader11EncodedSizeEv @ 112 NONAME
+ _ZNK11CObexHeader2HIEv @ 113 NONAME
+ _ZNK11CObexHeader4TypeEv @ 114 NONAME
+ _ZNK11CObexHeader5CopyLEv @ 115 NONAME
+ _ZNK11CObexHeader6AsByteEv @ 116 NONAME
+ _ZNK11CObexHeader9AsByteSeqEv @ 117 NONAME
+ _ZNK11CObexHeader9AsUnicodeEv @ 118 NONAME
+ _ZNK11CObexServer16CurrentOperationEv @ 119 NONAME
+ _ZNK14CObexHeaderSet4FindEhR11CObexHeader @ 120 NONAME
+ _ZNK14CObexHeaderSet4NextEi @ 121 NONAME
+ _ZNK14CObexHeaderSet4NextEv @ 122 NONAME
+ _ZNK14CObexHeaderSet4ThisEP11CObexHeader @ 123 NONAME
+ _ZNK14CObexHeaderSet5CountEv @ 124 NONAME
+ _ZNK14CObexHeaderSet5FirstEv @ 125 NONAME
+ _ZNK15CObexBaseObject4HttpEv @ 126 NONAME
+ _ZNK15CObexBaseObject8AppParamEv @ 127 NONAME
+ _ZNK15CObexBaseObject9HeaderSetEv @ 128 NONAME
+ _ZNK16TObexConnectInfo12VersionMajorEv @ 129 NONAME
+ _ZNK16TObexConnectInfo12VersionMinorEv @ 130 NONAME
+ _ZNK19TObexProtocolPolicy10ReceiveMtuEv @ 131 NONAME
+ _ZNK19TObexProtocolPolicy11TransmitMtuEv @ 132 NONAME
+ _ZNK19TObexProtocolPolicy7VersionEv @ 133 NONAME
+ _ZNK5CObex10RemoteInfoEv @ 134 NONAME
+ _ZNK5CObex11IsConnectedEv @ 135 NONAME
+ _ZNK5CObex12ConnectStateEv @ 136 NONAME
+ _ZNK5CObex12IsStrictPeerEv @ 137 NONAME
+ _ZNK5CObex12TSetPathInfo6ParentEv @ 138 NONAME
+ _ZNK5CObex9LocalInfoEv @ 139 NONAME
+ _ZTI16MObexHeaderCheck @ 140 NONAME ; #<TI>#
+ _ZTI17MObexServerNotify @ 141 NONAME ; #<TI>#
+ _ZTI25MObexAuthChallengeHandler @ 142 NONAME ; #<TI>#
+ _ZTV16MObexHeaderCheck @ 143 NONAME ; #<VT>#
+ _ZTV17MObexServerNotify @ 144 NONAME ; #<VT>#
+ _ZTV25MObexAuthChallengeHandler @ 145 NONAME ; #<VT>#
+ _ZN11CObexClient4NewLER18TObexTransportInfo @ 146 NONAME
+ _ZN11CObexServer4NewLER18TObexTransportInfo @ 147 NONAME
+ _ZN11CObexClient22SetFinalPacketObserverEP24MObexFinalPacketObserver @ 148 NONAME
+ _ZN11CObexServer5StartEP22MObexServerNotifyAsync @ 149 NONAME
+ _ZN22MObexServerNotifyAsync25MOSNA_ExtensionInterfaceLE4TUidRPv @ 150 NONAME
+ _ZTI22MObexServerNotifyAsync @ 151 NONAME ; #<TI>#
+ _ZTV22MObexServerNotifyAsync @ 152 NONAME ; #<VT>#
+ _ZN11CObexServer25RequestIndicationCallbackEP15CObexBaseObject @ 153 NONAME
+ _ZN11CObexServer33RequestCompleteIndicationCallbackE13TObexResponse @ 154 NONAME
+ _ZN11CObexServer33RequestCompleteIndicationCallbackEi @ 155 NONAME
+ _ZN11CObexServer34RequestIndicationCallbackWithErrorE13TObexResponse @ 156 NONAME
+ _ZN11CObexServer34RequestIndicationCallbackWithErrorEi @ 157 NONAME
+ _ZNK11CObexClient22LastServerResponseCodeEv @ 158 NONAME
+ _ZNK5CObex16IsAuthenticatingEv @ 159 NONAME
+ _ZN11CObexClient17SetCommandTimeOutE27TTimeIntervalMicroSeconds32 @ 160 NONAME
+ _ZN11CObexClient18ExtensionInterfaceE4TUid @ 161 NONAME
+ _ZN11CObexServer13PacketHeadersERP14CObexHeaderSet @ 162 NONAME
+ _ZN11CObexServer13PacketHeadersERP14CObexHeaderSetR16MObexHeaderCheck @ 163 NONAME
+ _ZN11CObexServer19ExtensionInterfaceLE4TUid @ 164 NONAME
+ _ZN5CObex36SuppressAuthenticationHeaderElementsENS_27TObexSuppressedAuthElementsE @ 165 NONAME
+ _ZNK11CObexServer13TransportInfoEv @ 166 NONAME
+ _ZN11CObexServer23SetReadActivityObserverEP25MObexReadActivityObserver @ 167 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/group/bld.inf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,60 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implementation of Object Exchange Protocol
+//
+//
+
+/**
+ @file
+*/
+
+PRJ_EXPORTS
+
+../public/OBEX.H SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obex.h)
+../public/obexbase.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexbase.h)
+../public/obexbaseobject.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexbaseobject.h)
+../public/obexclient.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexclient.h)
+../public/obexconstants.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexconstants.h)
+../public/obexpanics.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexpanics.h)
+../public/obexheaders.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexheaders.h)
+../public/obexobjects.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexobjects.h)
+../public/obexserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexserver.h)
+../public/obextypes.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obextypes.h)
+../public/obexfinalpacketobserver.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexfinalpacketobserver.h)
+../public/obexreadactivityobserver.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obexreadactivityobserver.h)
+../inc/obexconstantsinternal.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obexconstantsinternal.h)
+// NB obexcommontransport depends on these files to compile, but obex depends
+// on obexcommontransport to link. This is a circular dependency. Due to how
+// our build system works (export all the headers before trying to build
+// anything) it doesn't cause a build break.
+../public/ObexBtTransportInfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexbttransportinfo.h)
+../public/ObexUsbTransportInfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexusbtransportinfo.h)
+../public/ObexTransportInfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obextransportinfo.h)
+../public/ObexIrTransportInfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(obexirtransportinfo.h)
+
+PRJ_MMPFILES
+obex.mmp
+irobex.mmp // Build irobex.lib to allow legacy components to continue linking without source changes
+
+
+PRJ_TESTEXPORTS
+../test/tobex/Contactsbak.vcf /epoc32/wins/c/contactsbak.vcf
+../test/tobex/Contactsbak2.vcf /epoc32/wins/c/contactsbak2.vcf
+../test/tobex/Contactsbak3.vcf /epoc32/wins/c/contactsbak3.vcf
+
+PRJ_TESTMMPFILES
+
+../test/tobex/TOBEX.MMP
+../test/testobexerrorcodes/TestObexErrorCodes.mmp
+../test/headercheck/group/t_obexheadercheck.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/group/irobex.mmp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,33 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Obex
+// irobex.lib Build irobex.lib to allow legacy apps to effectively link to obex.dll
+//
+//
+
+/**
+ @file
+*/
+
+TARGET irobex.lib
+TARGETTYPE IMPLIB
+#ifdef WINSCW
+DEFFILE IROBEX2.DEF
+#else
+DEFFILE irobex2.def
+#endif
+UID 0x1000008d 0x10201EF5
+LINKAS obex.dll
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/group/obex.mmp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,101 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Obex
+// irobex.dll Implementation of Object Exchange Protocol
+//
+//
+
+/**
+ @file
+*/
+
+
+TARGET obex.dll //Recommended unpaged
+
+CAPABILITY All -Tcb
+TARGETTYPE dll
+
+uid 0x1000008d 0x10201EF5
+
+#ifdef WINSCW
+DEFFILE IROBEX2.DEF
+#else
+DEFFILE irobex2.def
+#endif
+
+SOURCEPATH ../src
+SOURCE OBEX.CPP
+SOURCE obexobjectexpandedbaseobject.cpp
+SOURCE obexheader.cpp
+SOURCE obexheaderset.cpp
+SOURCE obexconstants.cpp
+SOURCE obexheaderutil.cpp
+SOURCE obexobjects.cpp
+SOURCE obexclient.cpp
+SOURCE obexserver.cpp
+SOURCE obexserverstatemachine.cpp
+SOURCE obexfilewriter.cpp
+SOURCE obexasyncfilewriter.cpp
+SOURCE obexsyncfilewriter.cpp
+SOURCE obexsetpathdata.cpp
+SOURCE OBEXUTIL.CPP
+SOURCE authentication.cpp
+SOURCE obexservernotify.cpp
+SOURCE obexauthchallengehandler.cpp
+SOURCE obexpacketsignaller.cpp
+SOURCE obexpackettimer.cpp
+SOURCE obexnotifyhandlerbase.cpp
+SOURCE obexnotifyhandlerclient.cpp
+SOURCE obexnotifyhandlerserver.cpp
+SOURCE obexservernotifysyncwrapper.cpp
+SOURCE obexserverrequestpacketengine.cpp
+SOURCE obexerrorengine.cpp
+SOURCE TObexServerOperationState.cpp
+SOURCE TObexServerStateDisconnected.cpp
+SOURCE TObexServerStateTransportConnected.cpp
+SOURCE TObexServerStateObexConnecting.cpp
+SOURCE TObexServerStateWaitForUserPassword.cpp
+SOURCE TObexServerStateReady.cpp
+SOURCE TObexServerStatePutOpWaitForUser.cpp
+SOURCE TObexServerStatePutOpReceiveObject.cpp
+SOURCE TObexServerStateGetOpReceiveSpecification.cpp
+SOURCE TObexServerStateGetOpWaitForUser.cpp
+SOURCE TObexServerStateGetOpSendObject.cpp
+SOURCE TObexServerStateSetPathOp.cpp
+SOURCE TObexServerStatePutOpFinal.cpp
+SOURCE TObexServerStateGetOpFinal.cpp
+SOURCE TObexServerStateDisconnecting.cpp
+
+USERINCLUDE ../inc
+USERINCLUDE ../../common
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY euser.lib
+LIBRARY efsrv.lib
+LIBRARY esock.lib
+LIBRARY hash.lib
+LIBRARY charconv.lib
+LIBRARY obexcommontransport.lib
+LIBRARY irda.lib // Needed by IrOBEXUtil::CreateTransportInfoL
+LIBRARY bluetooth.lib // Needed by IrOBEXUtil::CreateTransportInfoL
+LIBRARY ecom.lib
+
+START WINS
+ BASEADDRESS 0x73900000
+END
+
+VENDORID 0x70000001
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/OBEXUTIL.H Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,51 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+//defined for testing purposes only
+//#define TEST_CLIENT_CHANGES_ITS_MIND_ABOUT_CHALLENGE
+
+#ifndef __OBEXUTIL_H
+#define __OBEXUTIL_H
+
+#include <obexconstants.h>
+#include "obexconstantsinternal.h"
+#include "obexfaults.h"
+
+class TObexTransportInfo;
+
+//this macro traps the leave and if an error has occured it calls the function defined by _trap
+#define OBEX_TRAP(_trap, _stmt) TRAPD(_code, _stmt);if(_code != KErrNone) _trap (_code)
+
+inline TInt ObexHeaderType(TUint8 aHI)
+ {
+ return ((aHI & KObexHeaderTypeMask) >> KObexHeaderTypeOffset);
+ }
+
+NONSHARABLE_CLASS(IrOBEXUtil)
+ {
+public:
+ static void Panic(TObexPanicCode aCode);
+ static void Fault(TObexFaultCode aCode);
+ static TInt EpocError(TUint8 aResp);
+ static TObexResponse ObexResponse(TInt aErr,TObexResponse aDefault);
+ static TObexTransportInfo* CreateTransportInfoL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy);
+ };
+
+#endif // __OBEXUTIL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/authentication.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,49 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef AUTHENTICATION_H
+#define AUTHENTICATION_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <obex.h>
+#include <obex/internal/obextransportconstants.h>
+
+const TUid KObexAuthenticationNotifierUid = {0x12341234}; //fixme
+
+class CMD5;
+
+NONSHARABLE_CLASS(CObexAuthenticator) : public CBase
+ {
+public:
+ static CObexAuthenticator* NewL();
+ ~CObexAuthenticator();
+ TInt GenerateNonce(TDes8& aNonce);
+ void GenerateResponseL(const TDesC8& aPasswd, const TNonce& aNonce, TRequestDigest& aRequestDigest);
+ void ChallengeResponseL(const TDesC8& aPasswd, const TNonce& aNonce, const TRequestDigest& aRequestDigest);
+private:
+ void ConstructL();
+ CObexAuthenticator();
+private:
+ CMD5* iMD5;
+ TInt64 iSeed;
+ };
+
+#endif // AUTHENTICATION_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexasyncfilewriter.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,71 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __OBEXASYNCFILEWRITER_H__
+#define __OBEXASYNCFILEWRITER_H__
+
+#include <e32base.h>
+#include "obexfilewriter.h"
+
+class RFile;
+
+/**
+Obex Asynchronous File Writer.
+
+This active object writes data from Obex objects to disk asynchronously.
+
+Not intended for derivation.
+
+@internalComponent
+@released
+*/
+NONSHARABLE_CLASS(CObexAsyncFileWriter) : public CActive, public MObexFileWriter
+ {
+public:
+ // Construction / destruction
+ static MObexFileWriter* NewL(RFile& aFile);
+ ~CObexAsyncFileWriter();
+
+private:
+ // From MObexFileWriter
+ TInt Write(TInt aPos, CBufBase*& aBuf);
+ TInt FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength);
+
+private:
+ // From CActive
+ void DoCancel();
+ void RunL();
+
+private:
+ // Construction
+ void ConstructL();
+ CObexAsyncFileWriter(RFile& aFile);
+
+// Unowned
+private:
+ /** Reference to the file which this object is used to write to */
+ RFile& iFile;
+ /** Pointer to the buffer this object is currently writing to file */
+ CBufBase* iBuffer;
+ /** Descriptor for the buffer this object is currently writing to file */
+ TPtr8 iBufPtr;
+ };
+
+#endif // __OBEXASYNCFILEWRITER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexcommon.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,29 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __OBEXCOMMON_H__
+#define __OBEXCOMMON_H__
+
+#include <obextypes.h>
+#include <obexconstants.h>
+#include <obexbaseobject.h>
+#include <obexobjects.h>
+
+#endif // __OBEXCOMMON_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexconstantsinternal.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,125 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef __OBEXCONSTANTSINTERNAL_H
+#define __OBEXCONSTANTSINTERNAL_H
+
+#include <e32def.h>
+
+//common to request & resp digests
+
+/** @internalComponent */
+const TInt KMinChallResponseSize = 18; //Nonce(16) + tag(1) + size(1)
+/** @internalComponent */
+const TInt KObexNonceSize = 16;
+/** @internalComponent */
+const TUint8 KObexRequireUID = 0x01;
+
+//request or chall
+/** @internalComponent */
+const TUint KObexChallNonceTag = 0;
+/** @internalComponent */
+const TUint8 KObexChallOptionsTag = 0x01;
+/** @internalComponent */
+const TUint8 KObexChallRealmTag = 0x02;
+/** @internalComponent */
+const TInt KObexChallOptionSize = 1; //this can't be changed from one without making
+/** @internalComponent */
+const TUint KObexChallHeaderSize = 23; //assuming no Realm data
+
+//response
+/** @internalComponent */
+const TUint KObexRespTag = 0;
+/** @internalComponent */
+const TUint8 KObexRespUserIDTag = 0x01;
+/** @internalComponent */
+const TUint8 KObexRespNonceTag = 0x02;
+
+/** @internalComponent */
+const TUint8 KObexHeaderTypeMask = 0xc0;
+/** @internalComponent */
+const TUint8 KObexHeaderTypeOffset = 6;
+
+
+#ifdef _UNICODE
+/** @internalComponent */
+const TInt KUidOBEXTransportModule = 0x10003d56;
+#else
+/** @internalComponent */
+const TInt KUidOBEXTransportModule = 0x1000169c;
+#endif
+
+/** @internalComponent */
+const TUint8 KFourByteTimeHeaderAddress = 0xc4;
+
+// Header mask definitions.
+// Old style accessor for which headers are present or
+// should be sent by an object. Now deprecated, use the
+// header iterator instead.
+/** @internalComponent */
+const TUint16 KObexHdrName = 0x0001;
+/** @internalComponent */
+const TUint16 KObexHdrType = 0x0002;
+/** @internalComponent */
+const TUint16 KObexHdrLength = 0x0004;
+/** @internalComponent */
+const TUint16 KObexHdrTime = 0x0008;
+/** @internalComponent */
+const TUint16 KObexHdrDescription = 0x0010;
+/** @internalComponent */
+const TUint16 KObexHdrTarget = 0x0020;
+/** @internalComponent */
+const TUint16 KObexHdrConnectionID = 0x0040;
+/** @internalComponent */
+const TUint16 KObexHdrBody = 0x0080;
+/** @internalComponent */
+const TUint16 KObexHdrEndOfBody = 0x0100;
+/** @internalComponent */
+const TUint16 KObexHdrHttp = 0x0200;
+/** @internalComponent */
+const TUint16 KObexHdrAppParam = 0x0400;
+/** @internalComponent */
+const TUint16 KObexHdrUserDefined = 0x0800;
+/** @internalComponent */
+const TUint16 KObexHdrCount = 0x1000;
+/** @internalComponent */
+const TUint16 KObexHdrCreatorID = 0x2000;
+/** @internalComponent */
+const TUint16 KObexHdrWanUUID = 0x4000;
+/** @internalComponent */
+const TUint16 KObexHdrObjectClass = 0x8000;
+
+
+/** @internalComponent */
+const TUint8 KObexUserDefinedHdrAddrMin = 0x30; //start of user defined header address range
+/** @internalComponent */
+const TUint8 KObexUserDefinedHdrAddrMax = 0x3F; //end of user defined header address range
+
+/** @internalComponent */
+const TUint8 KObexVersion = 0x10; //< Version 1.0 (still correct for Obex spec v 1.2)
+
+/** @internalComponent */
+const TUint8 KObexObjectFieldSize = 127;
+
+// Flags used by SetPath
+/** @internalComponent */
+const TUint8 KObexSetPathParent = 0x01;
+
+#endif // __OBEXCONSTANTSINTERNAL_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexerrorengine.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,219 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __OBEXERRORENGINE_H
+#define __OBEXERRORENGINE_H
+
+#include <obex/internal/mobexclienterrorresolver.h>
+
+/**
+Implements the Obex client error resolver extension functionality.
+Keeps a record of the last underlying client error that occurred.
+Resolves the underlying error to an error set specified by the user.
+*/
+NONSHARABLE_CLASS(CObexErrorEngine) : public CBase, public MObexClientErrorResolver
+ {
+public:
+ /**
+ The Obex client sets a detailed "underlying" error on the error
+ engine for resolving to a specific error set later on. This
+ mechanism adds extensibility to different error sets.
+ */
+ enum TObexClientUnderlyingError
+ {
+ /**
+ No error in the last operation.
+ @see CObexClient::OnPacketReceive()
+ */
+ ENoError = 0,
+
+ /**
+ The last operation failed to bring the transport up.
+ @see CObexClient::ClientCommandL()
+ @see CObexClient::CompleteRequest()
+ */
+ ETransportUpFailed = 1,
+
+ /**
+ Tried to connect but already connected.
+ @see CObexClient::ClientCommandL()
+ */
+ EAlreadyConnected = 2,
+
+ /**
+ Failed to insert local connection info into connect packet.
+ @see CObexClient::PrepareConnectPacket()
+ */
+ ECannotInsertConnectInfo = 3,
+
+ /**
+ Connection challenge received but unable to ask the user for a password.
+ @see CObexClient::PrepareConnectPacket()
+ */
+ EChallengeRejected = 4,
+
+ /**
+ The client's connect state was set to an erroneous value.
+ @see CObexClient::PrepareConnectPacket()
+ */
+ EPrepareConnectPacketIncorrectState = 5,
+
+ /**
+ A packet was received while the client was sending.
+ @see CObexClient::OnPacketReceive()
+ */
+ EResponseWhileWriting = 6,
+
+ /**
+ Failed to extract remote connection info from server connect packet.
+ @see CObexClient::ParseConnectPacket()
+ */
+ ECannotExtractConnectInfo = 7,
+
+ /**
+ Cannot process the challenge/challenge response from the server.
+ @see CObexClient::ParseConnectPacket()
+ */
+ ECannotProcessChallenge = 8,
+
+ /**
+ Challenge response received but the client did not request one.
+ @see CObexClient::ParseConnectPacket()
+ */
+ EUnexpectedChallengeResponse = 9,
+
+ /**
+ Unauthorised opcode in server connect packet and there is no challenge header.
+ This means that the server failed to authenticate the client.
+ @see CObexClient::ParseConnectPacket()
+ */
+ EChallengeAbsent = 10,
+
+ /**
+ The server connect packet contained an unknown opcode.
+ @see CObexClient::ParseConnectPacket()
+ */
+ EBadOpcodeInConnectPacket = 11,
+
+ /**
+ The client operation timed out.
+ @see CObexClient::TimeoutCompletion()
+ */
+ EResponseTimeout = 12,
+
+ /**
+ The client operation was aborted by the user.
+ @see CObexClient::OnPacketReceive()
+ */
+ EAborted = 13,
+
+ /**
+ The transport went down while an operation was outstanding.
+ @see CObexClient::OnTransportDown()
+ @see CObexClient::CompleteRequest()
+ */
+ EOpOutstandingOnTransportDown = 14,
+
+ /**
+ The server refused the disconnection request
+ because it did not recognise the connection ID.
+ @see CObexClient::OnPacketReceive()
+ */
+ EBadConnectionId = 15,
+
+ /**
+ The client attempted an operation other than connect while disconnected.
+ @see CObexClient::ClientCommandL()
+ */
+ EDisconnected = 16,
+
+ /**
+ Could not initialise the object to be sent in the Put/Get request.
+ @see CObexClient::ClientCommandL()
+ */
+ ECannotInitialiseObject = 17,
+
+ /**
+ Could not set the connection ID on the
+ object to be sent in the Put/Get request.
+ @see CObexClient::ClientCommandL()
+ */
+ ECannotSetConnectionId = 18,
+
+ /**
+ Could not prepare the next send packet in the Put/Get request.
+ @see CObexClient::ClientCommandL()
+ */
+ ECannotPreparePacket = 19,
+
+ /**
+ Multipacket response from server to Put/Get (not GetResponse) request.
+ @see CObexClient::OnPacketReceive()
+ */
+ EMultipacketResponse = 20,
+
+ /**
+ The response from the server contained an error code.
+ @see CObexClient::OnPacketReceive()
+ */
+ EErrorResponseFromServer = 21,
+
+ /**
+ Could not extract the header from the final Put response packet.
+ @see CObexClient::OnPacketReceive()
+ */
+ ECannotExtractFinalPutHeader = 22,
+
+ /**
+ The opcode of the Put response packet from the server is
+ not consistent with the progress of the Put operation.
+ @see CObexClient::OnPacketReceive()
+ */
+ EPutOutOfSync = 23,
+
+ /**
+ The opcode of the Get response packet from the server is Success
+ but the client hasn't finished sending all the Get request packets.
+ @see CObexClient::OnPacketReceive()
+ */
+ EGetPrematureSuccess = 24,
+
+ /**
+ Could not parse a GetResponse packet from the server.
+ @see CObexClient::OnPacketReceive()
+ */
+ EGetResponseParseError = 25,
+ };
+
+ static CObexErrorEngine* NewL();
+
+ // Implements MObexClientErrorResolver::LastError().
+ virtual TUint LastError(TObexClientErrorResolutionSetType aErrorSet) const;
+
+ void SetLastError(TObexClientUnderlyingError aError);
+
+private:
+ CObexErrorEngine();
+
+private:
+ TObexClientUnderlyingError iLastError;
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexfaults.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,208 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEX_FAULTS_H
+#define OBEX_FAULTS_H
+
+/**
+@file
+@internalComponent
+
+This file contains details of all Obex panics which may be raised as a result
+of an internal programming error.
+*/
+
+
+/**
+Category for Obex faults
+*/
+_LIT(KObexFaultCategory, "ObexFault");
+
+
+/**
+Obex fault codes
+*/
+enum TObexFaultCode
+ {
+ /** USB has entered an unknown state. This probably means TUsbcDeviceState
+ has changed without Obex being updated accordingly.
+ @see TUsbcDeviceState
+ @see CObexUsbHandler
+ */
+ EUnknownUsbState = 0,
+
+
+ /** The object still has references to it on destruction.
+ @see CRefCounted
+ */
+ ERefCountNonZero = 1,
+
+
+ /** An attempt has been made to construct an unknown buffering details
+ object.
+ @see TObexBufferingDetails
+ */
+ EBadBufferDetailsVersion = 2,
+
+
+ /** No receive packet is available to return.
+ @see CObexServerStateMachine
+ */
+ ENoReceivePacketAvailable = 3,
+
+
+ /** No notifier has been set to notify of an event.
+ Server should not be started without a notifier, so event handling is
+ not expected to occur.
+ @see CObexServerStateMachine
+ */
+ ENoNotifierAvailable = 4,
+
+
+ /** Synchronous state wrapper has been errored when calling
+ CObexServer::RequestIndicationCallback().
+ @see CObexServerSyncWrapper
+ */
+ ESyncWrapperCallbackError = 5,
+
+
+ /** An unexpected event has been sent to the state machine
+ @see CObexServer
+ @see CObexServerStateMachine
+ */
+ EServerStateMachineBadEvent = 6,
+
+ /** CreateTransportInfoL has been given an unrecognised
+ TObexProtocolInfo::iTransport, and has therefore been unable to create a
+ TObexTransportInfo.
+ @see IrOBEXUtil
+ */
+ EUtilNoTransportInfo = 7,
+
+ /** CObex::TransportDown() has been called
+ This is a legacy function that is retained for backwards compatibility.
+ It does not do anything and should not be called
+ @see CObex::TransportDown()
+ */
+ ETransportDownCalled = 8,
+
+ /** RespondAndEndOperation has been called, but the authentication
+ state machine does not think there is an OBEX connection
+ @see TObexServerOperationState::RespondAndEndOperation
+ */
+ ERespondAndEndOpWithoutObexConnection = 9,
+
+ /** CObexClient::ClientCommandL() does not recognise the operation
+ code value it is supplied.
+ @see CObexClient::ClientCommandL()
+ */
+ EClientCommandOpUnrecognised = 10,
+
+ /** CObexErrorEngine::LastError() does not recognise the error set
+ argument it is supplied.
+ @see CObexErrorEngine::LastError()
+ */
+ EErrorSetUnrecognised = 11,
+
+ /** CObexErrorEngine::LastError() does not recognise the underlying
+ error value that has been set.
+ @see CObexErrorEngine::LastError()
+ */
+ EUnderlyingErrorUnrecognised = 12,
+
+ /** The last underlying error is set twice during the lifetime
+ of a client operation.
+ @see CObexClient
+ */
+ ELastErrorSetTwice = 13,
+
+ /** The last underlying error was not set during the lifetime
+ of a client operation.
+ @see CObexClient
+ */
+ ELastErrorNotSet = 14,
+
+ /** OnPacketReceive has been called but the state machine does not
+ believe the server to have been started.
+ @see CObexServerStateMachine::OnPacketReceive
+ */
+ EPacketReceivedWhenServerNotStarted = 15,
+
+ /** ConnectionComplete has been called but the state machine does
+ not believe the server to have been started.
+ @see CObexServerStateMachine::ConnectionComplete
+ */
+ EConnectionCompleteWhenServerStopped = 16,
+
+ /** Put received in bad state. Note that all states where a put
+ is expected to be possible (even if due to invalid remote
+ behaviour) override the base implementation.
+ @see TObexServerOperationState::Put
+ */
+ EPutInBadState = 17,
+
+ /** Get received in bad state. Note that all states where a get
+ is expected to be possible (even if due to invalid remote
+ behaviour) override the base implementation.
+ @see TObexServerOperationState::Get
+ */
+ EGetInBadState = 18,
+
+ /** SetPath received in bad state. Note that all states where a
+ setpath is expected to be possible (even if due to invalid remote
+ behaviour) override the base implementation.
+ @see TObexServerOperationState::SetPath
+ */
+ ESetPathInBadState = 19,
+
+ /** Abort received in bad state. Note that all states where an
+ abort is expected to be possible (even if due to invalid remote
+ behaviour) override the base implementation.
+ @see TObexServerOperationState::Abort
+ */
+ EAbortInBadState = 20,
+
+ /** ConnectionComplete received in bad state. Note that all states where
+ this is expected to be possible (even if due to invalid remote
+ behaviour) override the base implementation.
+ @see TObexServerOperationState::ConnectionComplete
+ */
+ EConnectionCompleteInBadState = 21,
+
+ /** TransportUp received in bad state. Note that all states where
+ this is expected to be possible override the base implementation.
+ @see TObexServerOperationState::TransportUp
+ */
+ ETransportUpInBadState = 22,
+
+ /** Connect received in bad state. Note that all states where
+ this is expected to be possible override the base implementation.
+ @see TObexServerOperationState::Connect
+ */
+ EConnectInBadState = 23,
+
+ /** Disconnect received in bad state. Note that all states where
+ this is expected to be possible override the base implementation.
+ @see TObexServerOperationState::Disconnect
+ */
+ EDisconnectInBadState = 24,
+
+ /** In the current implementation, the transport controller should be
+ created at CObex::ConstructL time and persist until ~CObex.
+ */
+ ETransportControllerNotCreated = 25,
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexfilewriter.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,101 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __OBEXFILEWRITER_H__
+#define __OBEXFILEWRITER_H__
+
+#include <e32base.h>
+
+/**
+Obex File Writer Interface
+
+This interface is used by Obex objects to write to disk.
+
+Note that this class is the interface to the strategies used as part of
+a Strategy pattern. CObexAsyncFileWriter and CObexSyncFileWriter provide
+the alternative strategy implementations, with CObexBufObject as the context
+for these strategies.
+
+@see CObexAsyncFileWriter
+@see CObexSyncFileWriter
+@see CObexBufObject
+
+@internalComponent
+@released
+*/
+NONSHARABLE_CLASS(MObexFileWriter)
+
+ {
+public:
+ /**
+ Write the buffer.
+
+ @param aPos The file position to write at
+ @param aBuf The buffer to write. This object will use the buffer
+ specified by the pointer and may return another buffer
+ to the caller by updating the pointer. If an error
+ occurs, the pointer will not be updated. Note that
+ this class never owns any buffers and that passing
+ a buffer to this function does not imply a transfer
+ of ownership
+ @return Symbian OS error code
+
+ @internalComponent
+ @released
+ */
+ virtual TInt Write(TInt aPos, CBufBase*& aBuf) =0;
+
+ /**
+ Write the final buffer of the file.
+
+ This method should synchronously write the
+ buffer, in order to complete writing a file.
+
+ @param aPos The file position to write at
+ @param aBuf The buffer to write. This object will use the buffer
+ specified by the pointer and may return another buffer
+ to the caller by updating the pointer. If an error
+ occurs, the pointer will not be updated. Note that
+ this class never owns any buffers and that passing
+ a buffer to this function does not imply a transfer
+ of ownership
+ @param aLength The amount of the buffer to write
+ @return Symbian OS error code
+
+ @internalComponent
+ @released
+ */
+ virtual TInt FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength) =0;
+
+ /**
+ Destructor.
+
+ The usage pattern of MObexFileWriter is such that implementors' NewL
+ functions return pointers to MObexFileWriter, and clients use them only
+ via pointers to MObexFileWriter. Therefore a virtual destructor is
+ required for complete cleanup of implementor objects.
+
+ @internalComponent
+ @released
+ */
+ virtual ~MObexFileWriter();
+ };
+
+#endif // __OBEXFILEWRITER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexheaderutil.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,38 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __OBEXHEADERUTIL_H__
+#define __OBEXHEADERUTIL_H__
+
+class TObexInternalHeader;
+class CObexHeaderSet;
+class CObexHeader;
+
+NONSHARABLE_CLASS(IrOBEXHeaderUtil)
+ {
+public:
+ static TInt ParseHeader(TObexInternalHeader& aHeader, CObexHeaderSet& aHeaderSet);
+ static CObexHeader* CreateAndSetUnicodeHeader(const TUint8 aHI, const TDesC16& aUnicode);
+ static CObexHeader* CreateAndSetByteSeqHeader(const TUint8 aHI, const TDesC8& aByteSeq);
+ static CObexHeader* CreateAndSetUnicodeHeaderL(const TUint8 aHI, const TDesC16& aUnicode);
+ static CObexHeader* CreateAndSetByteSeqHeaderL(const TUint8 aHI, const TDesC8& aByteSeq);
+ };
+
+#endif // __OBEXHEADERUTIL_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexnotifyhandlerbase.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,66 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXNOTIFYHANDLERBASE_H
+#define OBEXNOTIFYHANDLERBASE_H
+
+/**
+@file
+@released
+@internalComponent
+*/
+
+#include <obex.h>
+#include <obex/internal/mobexnotifyextend.h>
+
+class CObexPacket;
+struct TObexConnectionInfo;
+/** Receives notifications from transport.
+
+This is provided as a way of retaining BC for the CObexClient and
+CObexServer classes.
+
+This class implements the MObexNotifyExtend interface which is provided
+to the transport. Functions can safely be added to MObexNotifyExtend to
+allow the transport to provide additional notifications in future without
+altering the vtable for the published classes.
+
+A CObex owns a CObexNotifyHandlerBase. The CObexNotifyHandler base
+should not be instantiated directly, instead one of the derived classes
+should be used. The derived class then knows the type of the CObex
+object created it, as the constructor will require an appropriately
+derived type. This allows the non-virtual functions in the appropriate
+class to be called to handle notifications.
+
+Functions that are generic CObex functions, rather than functions that
+are handled differently by CObexClient and CObexServer, may be implemented
+in the base class.
+*/
+NONSHARABLE_CLASS(CObexNotifyHandlerBase) : public CBase, public MObexNotifyExtend
+ {
+public:
+ virtual void Process(CObexPacket& aPacket);
+ virtual void Error(TInt aError);
+ virtual void TransportUp();
+ virtual void TransportDown(TBool aForceTransportDeletion);
+
+protected:
+ CObexNotifyHandlerBase(CObex& aObex);
+
+protected:
+ CObex& iObex;
+ };
+
+#endif // OBEXNOTIFYHANDLERBASE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexnotifyhandlerclient.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,42 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXNOTIFYHANDLERCLIENT_H
+#define OBEXNOTIFYHANDLERCLIENT_H
+
+/**
+@file
+@released
+@internalComponent
+*/
+
+#include "obexnotifyhandlerbase.h"
+
+class CObexClient;
+/** Recieves notifications from transport.
+
+This handles MObexNotifyExtend functions that require knowledge
+that the CObex that owns this class is a CObexClient.
+*/
+NONSHARABLE_CLASS(CObexNotifyHandlerClient) : public CObexNotifyHandlerBase
+ {
+public:
+ CObexNotifyHandlerClient(CObexClient& aObex);
+
+private:
+ virtual void SignalPacketProcessEvent(TObexPacketProcessEvent aEvent);
+ };
+
+#endif // OBEXNOTIFYHANDLERCLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexnotifyhandlerserver.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,42 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXNOTIFYHANDLERSERVER_H
+#define OBEXNOTIFYHANDLERSERVER_H
+
+/**
+@file
+@released
+@internalComponent
+*/
+
+#include "obexnotifyhandlerbase.h"
+
+class CObexServer;
+/** Recieves notifications from transport.
+
+This handles MObexNotifyExtend functions that require knowledge
+that the CObex that owns this class is a CObexServer.
+*/
+NONSHARABLE_CLASS(CObexNotifyHandlerServer) : public CObexNotifyHandlerBase
+ {
+public:
+ CObexNotifyHandlerServer(CObexServer& aObex);
+
+private:
+ virtual void SignalPacketProcessEvent(TObexPacketProcessEvent aEvent);
+ };
+
+#endif // OBEXNOTIFYHANDLERSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexpacketsignaller.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,62 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXPACKETSIGNALLER_H
+#define OBEXPACKETSIGNALLER_H
+
+/**
+@file
+@internalComponent
+@released
+*/
+
+#include <e32base.h>
+#include <obexfinalpacketobserver.h>
+#include <obexreadactivityobserver.h>
+#include <obex/transport/mobextransportnotify.h>
+
+const TUint KObexPacketSignallerInterestingEvents = EObexFinalPacketStarted | EObexFinalPacketFinished | EObexReadActivityDetected;
+const TUint KObexPacketSignallerInterestingClientEvents = EObexFinalPacketStarted | EObexFinalPacketFinished;
+
+/** This class handles packet process events.
+
+Currently the only events handled are those for final packet
+notification and read activity.
+*/
+NONSHARABLE_CLASS(CObexPacketSignaller) : public CActive
+ {
+public:
+ static CObexPacketSignaller* NewL();
+ virtual ~CObexPacketSignaller();
+
+ void SetFinalPacketObserver(MObexFinalPacketObserver* aObserver);
+ void SetReadActivityObserver(MObexReadActivityObserver* aObserver);
+ void Signal(TObexPacketProcessEvent aEvent);
+
+private:
+ CObexPacketSignaller();
+
+ void RunL();
+ void DoCancel();
+
+ void NotifyObserver(TObexPacketProcessEvent aEvent);
+
+private:
+ MObexFinalPacketObserver* iFinalPacketObserver;
+ MObexReadActivityObserver* iReadActivityObserver;
+ TObexPacketProcessEvents iOutstandingEvents;
+ };
+
+#endif // OBEXPACKETSIGNALLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexpackettimer.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,50 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXPACKETTIMER_H
+#define OBEXPACKETTIMER_H
+
+/**
+@file
+@internalComponent
+@released
+*/
+
+#include <e32base.h>
+
+const TInt KLowestPossibleTimerValue = 0;
+
+/** This class handles the timing of Obex reponse packets
+ from the server
+*/
+class CObexClient;
+
+NONSHARABLE_CLASS(CObexPacketTimer) : public CTimer
+ {
+public:
+ static CObexPacketTimer* NewL(CObexClient& aObexClient);
+ virtual ~CObexPacketTimer();
+
+ void SetTimer(TTimeIntervalMicroSeconds32 anInterval);
+
+private:
+ CObexPacketTimer(CObexClient& aObexClient);
+ virtual void RunL();
+
+private:
+ CObexClient& iObexClient;
+ };
+
+#endif // OBEXPACKETTIMER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexservernotifysyncwrapper.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,78 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// All rights reserved.
+//
+//
+
+#ifndef OBEXSERVERNOTIFYSYNCWRAPPER_H
+#define OBEXSERVERNOTIFYSYNCWRAPPER_H
+
+
+/**
+@file
+@internalComponent
+*/
+
+#include <e32base.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KSyncWrapper, "syncwrapper");
+
+#define WRAPPER_LOG(str) CObexLog::Write(KSyncWrapper, str)
+#else
+#define WRAPPER_LOG(str)
+#endif
+
+/**
+Implements a synchronous wrapper around the asynchronous notification API
+now used by the Obex server. It therefore provides an SC and BC migration
+path for existing code.
+@see MObexServerNotify
+@see MObexServerNotifyAsync
+*/
+NONSHARABLE_CLASS(CObexServerNotifySyncWrapper) : public CBase, public MObexServerNotifyAsync
+ {
+public:
+ static CObexServerNotifySyncWrapper* NewL(CObexServer& aOwner, CObexServerStateMachine& aStateMachine);
+ ~CObexServerNotifySyncWrapper();
+ void SetNotifier(MObexServerNotify* aNotify);
+
+private:
+ CObexServerNotifySyncWrapper(CObexServer& aOwner, CObexServerStateMachine& aStateMachine);
+
+private:
+ // From MObexServerNotifyAsync
+ void ErrorIndication(TInt aError);
+ void TransportUpIndication();
+ void TransportDownIndication();
+ void ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo);
+ void ObexDisconnectIndication(const TDesC8& aInfo);
+ void PutRequestIndication();
+ TInt PutPacketIndication();
+ void PutCompleteIndication();
+ void GetRequestIndication(CObexBaseObject* aRequiredObject);
+ TInt GetPacketIndication();
+ void GetCompleteIndication();
+ void SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo);
+ void AbortIndication();
+ void CancelIndicationCallback();
+
+private:
+ CObexServer& iOwner;
+ MObexServerNotify* iNotify;
+ TBool iCallbackOutstanding;
+ CObexServerStateMachine& iStateMachine;
+ };
+
+#endif // OBEXSERVERNOTIFYSYNCWRAPPER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexserveroperationstates.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,425 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEX_SERVER_OPERATION_STATES_H
+#define OBEX_SERVER_OPERATION_STATES_H
+
+/**
+@file
+@internalComponent
+
+Defines base state class and derived state classes for each operation
+*/
+
+#include <obextypes.h>
+#include "logger.h"
+
+static const TInt KMaxStatenameLength = 32;
+
+/**
+Defines the state class interface and default operations for events
+Also provides utility functions for common actions
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerOperationState)
+ {
+public:
+ // Default implementation of events
+ virtual void Entry(CObexServerStateMachine& aContext);
+
+ virtual void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+
+ virtual void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+
+ virtual void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+
+ virtual void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+
+ virtual void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+
+ virtual void Abort(CObexServerStateMachine& aContext);
+
+ virtual void TransportUp(CObexServerStateMachine& aContext);
+
+ virtual void Start(CObexServerStateMachine& aContext);
+
+ virtual void Reset(CObexServerStateMachine& aContext);
+
+ virtual void RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject);
+
+ virtual void RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+
+ virtual void RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+
+ virtual void ConnectionComplete(CObexServerStateMachine& aContext);
+
+ virtual void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+ virtual TBool ValidResponse(TObexResponse aResponseCode);
+
+ virtual void WriteComplete(CObexServerStateMachine& aContext);
+
+ virtual void ReadActivityDetected(CObexServerStateMachine& aContext);
+
+
+protected:
+ // Utility functions
+ static void PerformDisconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ static void RespondAndEndOperation(CObexServerStateMachine& aContext, TObexResponse aResponseCode);
+
+#ifdef __FLOG_ACTIVE
+public:
+ TBuf8<KMaxStatenameLength> iName;
+#endif
+ };
+
+
+// State class definitions - defines methods for all the non-default events
+// default events are provided by TObexServerOperationState
+
+/**
+Initial unconnected state
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateDisconnected) : public TObexServerOperationState
+ {
+public:
+ TObexServerStateDisconnected();
+ void Entry(CObexServerStateMachine& aContext);
+ void TransportUp(CObexServerStateMachine& aContext);
+ void Reset(CObexServerStateMachine& aContext);
+ };
+
+/**
+Idle transport connected state (no OBEX connection)
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateTransportConnected) : public TObexServerOperationState
+ {
+public:
+ TObexServerStateTransportConnected();
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+ };
+
+/**
+Processes an OBEX connection attempt
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateObexConnecting) : public TObexServerOperationState
+ {
+public:
+ //Failure cases
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+ //Functional
+ TObexServerStateObexConnecting();
+ void Entry(CObexServerStateMachine& aContext);
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ };
+
+/**
+Waits for a password from the Application as part of connection attempt
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateWaitForUserPassword) : public TObexServerOperationState
+ {
+public:
+ //Failure
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void Start(CObexServerStateMachine& aContext);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+ //Functional
+ TObexServerStateWaitForUserPassword();
+ void ConnectionComplete(CObexServerStateMachine& aContext);
+ };
+
+/**
+Idle OBEX connected state
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateReady) : public TObexServerOperationState
+ {
+public:
+ TObexServerStateReady();
+ void Entry(CObexServerStateMachine& aContext);
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+ void ReadActivityDetected(CObexServerStateMachine& aContext);
+ };
+
+/**
+Waits for object to return to Client as part of PUT operation
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStatePutOpWaitForUser) : public TObexServerOperationState
+ {
+public:
+ //Failure cases
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void Start(CObexServerStateMachine& aContext);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+ //Functional
+ TObexServerStatePutOpWaitForUser();
+ void Entry(CObexServerStateMachine& aContext);
+ void Reset(CObexServerStateMachine& aContext);
+ void RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject);
+ void RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+ TBool ValidResponse(TObexResponse aResponseCode);
+
+ // Call-back function used by asynchronous one-shot
+ static TInt ProcessNotification(TAny* aPtr);
+ static TInt ProcessErrorNotification(TAny* aPtr);
+ };
+
+/**
+Receives object from Client as part of PUT operation
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStatePutOpReceiveObject) : public TObexServerOperationState
+ {
+public:
+ //Failure cases
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+ //Functional
+ TObexServerStatePutOpReceiveObject();
+ void Entry(CObexServerStateMachine& aContext);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ };
+
+/**
+Recevies from Client specification of object to GET
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateGetOpReceiveSpecification) : public TObexServerOperationState
+ {
+public:
+ //Failure cases
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+ //Functional
+ TObexServerStateGetOpReceiveSpecification();
+ void Entry(CObexServerStateMachine& aContext);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ };
+
+/**
+Waits for object to return to Client as part of GET operation
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateGetOpWaitForUser) : public TObexServerOperationState
+ {
+public:
+ //Failure cases
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void Start(CObexServerStateMachine& aContext);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+ //Functional
+ TObexServerStateGetOpWaitForUser();
+ void Entry(CObexServerStateMachine& aContext);
+ void Reset(CObexServerStateMachine& aContext);
+ void RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject);
+ void RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+ TBool ValidResponse(TObexResponse aResponseCode);
+
+ // Call-back function used by asynchronous one-shot
+ static TInt ProcessNotification(TAny* aPtr);
+ static TInt ProcessErrorNotification(TAny* aPtr);
+ };
+
+/**
+Returns requested object to Client as part of GET operation
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateGetOpSendObject) : public TObexServerOperationState
+ {
+public:
+ //Failure cases
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+ //Functional
+ TObexServerStateGetOpSendObject();
+ void Entry(CObexServerStateMachine& aContext);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ };
+
+/**
+Performs SETPATH operation and waits for user interaction
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateSetPathOp) : public TObexServerOperationState
+ {
+public:
+ //Failure cases
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void Start(CObexServerStateMachine& aContext);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+ //Functional
+ TObexServerStateSetPathOp();
+ void Entry(CObexServerStateMachine& aContext);
+ void Reset(CObexServerStateMachine& aContext);
+ void RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+ TBool ValidResponse(TObexResponse aResponseCode);
+
+ static TInt ProcessNotification(TAny* aPtr);
+ };
+
+/**
+Waits for user interaction after receiving the final PUT
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStatePutOpFinal) : public TObexServerOperationState
+ {
+public:
+ //Failure cases
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void Start(CObexServerStateMachine& aContext);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+ //Functional
+ TObexServerStatePutOpFinal();
+ void Entry(CObexServerStateMachine& aContext);
+ void Reset(CObexServerStateMachine& aContext);
+ void RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+ TBool ValidResponse(TObexResponse aResponseCode);
+
+ static TInt ProcessNotification(TAny* aPtr);
+private:
+ static void PrepareFinalResponseHeaderSet(CObexHeader* aHeader, CObexHeaderSet& aHeaderSet, CObexPacket& aPacket);
+ };
+
+/**
+Waits for user interaction after receiving the final Get
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateGetOpFinal) : public TObexServerOperationState
+ {
+public:
+
+ //Failure cases
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void Start(CObexServerStateMachine& aContext);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+ //Fucntional
+ TObexServerStateGetOpFinal();
+ void Reset(CObexServerStateMachine& aContext);
+ void Entry(CObexServerStateMachine& aContext);
+ void RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse);
+ TBool ValidResponse(TObexResponse aResponseCode);
+
+ static TInt ProcessNotification(TAny* aPtr);
+ };
+
+/**
+Disconnecting state
+@see TObexServerOperationState
+@see CObexServerStateMachine
+*/
+NONSHARABLE_CLASS(TObexServerStateDisconnecting) : public TObexServerOperationState
+ {
+public:
+ TObexServerStateDisconnecting();
+
+ //Failure cases
+ void Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Put(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Get(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void SetPath(CObexServerStateMachine& aContext, CObexPacket& aPacket);
+ void Abort(CObexServerStateMachine& aContext);
+ void OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse);
+
+ //Functional
+ void WriteComplete(CObexServerStateMachine& aContext);
+ };
+
+#endif // OBEX_SERVER_OPERATION_STATES_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexserverrequestpacketengine.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,61 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// NOTE: This class provides inline functions - DO NOT EXPORT THIS HEADER.
+//
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef OBEXSERVERREQUESTPACKETENGINE_H
+#define OBEXSERVERREQUESTPACKETENGINE_H
+
+#include <e32base.h>
+#include <obex/internal/mobexserverrequestpacketnotifyregister.h>
+
+class CObexServer;
+class MObexServerRequestPacketNotify;
+
+/**
+Utility class for CObexServer - to allow the OBEX Server extension API for
+packet access.
+*/
+NONSHARABLE_CLASS(CObexServerRequestPacketEngine) : public CBase, public MObexServerRequestPacketNotifyRegister
+ {
+public:
+ static CObexServerRequestPacketEngine* NewL(CObexServer& aServer);
+ ~CObexServerRequestPacketEngine();
+
+ virtual void SetObexServerRequestPacketObserver(MObexServerRequestPacketNotify& aPacketNotify);
+ virtual void DeleteObexServerRequestPacketNotifyRegister();
+
+ inline MObexServerRequestPacketNotify* RequestPacketNotify() const;
+
+private:
+ CObexServerRequestPacketEngine(CObexServer& aServer);
+
+private:
+ CObexServer& iServer;
+ MObexServerRequestPacketNotify* iRequestPacketNotify;
+ };
+
+inline MObexServerRequestPacketNotify* CObexServerRequestPacketEngine::RequestPacketNotify() const
+ {
+ return iRequestPacketNotify;
+ }
+
+#endif // OBEXSERVERREQUESTPACKETENGINE_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexserverstatemachine.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,146 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef OBEX_SERVER_STATE_MACHINE_H
+#define OBEX_SERVER_STATE_MACHINE_H
+
+#include <obextypes.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include "obexserveroperationstates.h"
+#include "OBEXUTIL.H"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KStateMachineCmpt, "statemachine");
+
+#define STATE_LOG(str) CObexLog::Write(KStateMachineCmpt, str)
+#define STATE_LOG_2(str, a, b) CObexLog::WriteFormat(KStateMachineCmpt, str, a, b)
+#else
+#define STATE_LOG(str)
+#define STATE_LOG_2(str, a, b)
+#endif
+
+/**
+The OBEX Server state machine's context.
+This class holds all the state context information and acts
+as the interface between CObexServer and the current state
+@see TObexServerOperationState
+*/
+NONSHARABLE_CLASS(CObexServerStateMachine) : public CBase
+ {
+public:
+ enum TObexServerOperationStateEnum
+ {
+ EDisconnected,
+ ETransportConnected,
+ EObexConnecting,
+ EWaitForUserPassword,
+ EReady,
+ EPutOpWaitForUser,
+ EPutOpReceiveObject,
+ EGetOpReceiveSpecification,
+ EGetOpWaitForUser,
+ EGetOpSendObject,
+ ESetPathOp,
+ EPutOpFinal,
+ EGetOpFinal,
+ EDisconnecting,
+ EEndOfStates
+ };
+
+ static CObexServerStateMachine* NewL(CObexServer& aOwner, CObexTransportControllerBase& aTransport);
+ ~CObexServerStateMachine();
+
+
+ // Events
+ void ChangeState(TObexServerOperationStateEnum aState);
+ void OnPacketReceive(CObexPacket& aPacket);
+ void TransportUp();
+ void TransportDown();
+ void Error();
+ TInt RequestNotificationCompleted(CObexBaseObject* aObject);
+ TInt RequestNotificationCompleted(TObexResponse aAppResponse);
+ TInt RequestCompleteNotificationCompleted(TObexResponse aAppResponse);
+ void ConnectionComplete();
+ void Start(MObexServerNotifyAsync& aNotify);
+ void Stop();
+ void OverrideRequestHandling(TObexResponse aResponse);
+ void WriteComplete();
+ void ReadActivityDetected();
+
+ // Getter/setter functions
+ CObexPacket& LastReceivedPacket() const; // no setter needed as is only ever set in OnPacketReceive()
+
+ // Object specifiying object to GET
+ CObexBaseObject* SpecObject() const; // Don't need a setter as we own
+
+ // Object returned from Application for GET/PUT
+ CObexBaseObject* TransObject() const;
+ void SetTransObject(CObexBaseObject* aTransObject);
+
+ // Access to CObexServer members
+ CObexTransportControllerBase& Transport() const;
+ CObexServer& Owner() const;
+ MObexServerNotifyAsync& Notification() const;
+
+ // Header set for final Put response
+ CObexHeaderSet* PutFinalResponseHeaderSet();
+ void SetPutFinalResponseHeaderSet(CObexHeaderSet* aHeaderSet);
+ CObexHeader* GetHeader(); // don't need setter as we own
+
+ // Call-back used to wrap NotificationComplete event
+ void CallBack(TInt (*aFunction)(TAny* aPtr));
+ void CancelCallBack();
+ TBool IsCallBackActive() const;
+ TObexResponse AppResponse() const;
+ void SetAppResponse(TObexResponse aAppResponse);
+
+ void ControlledTransportDown();
+
+private:
+ CObexServerStateMachine(CObexServer& aOwner, CObexTransportControllerBase& aTransport);
+ void ConstructL();
+
+private:
+ TFixedArray<TObexServerOperationState, EEndOfStates> iStates;
+ TObexServerOperationState* iCurrentState;
+
+ CObexPacket* iLastReceivedPacket;
+ CObexBaseObject* iSpecObject;
+ CObexBaseObject* iTransObject;
+ CObexTransportControllerBase& iTransport;
+
+ CObexServer& iOwner;
+ MObexServerNotifyAsync* iNotification;
+
+ CObexHeaderSet* iPutFinalResponseHeaderSet;
+ CObexHeader* iHeader;
+
+ TBool iServerStarted;
+
+ CAsyncCallBack* iCallBack;
+ TObexResponse iAppResponse;
+ TObexServerOperationStateEnum iCurrentStateEnum;
+ };
+
+#endif // OBEX_SERVER_STATE_MACHINE_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexsetpathdata.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,45 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __OBEXSETPATHDATA_H__
+#define __OBEXSETPATHDATA_H__
+
+#include <e32def.h>
+#include <obex/internal/obexdata.h>
+
+/**
+Contains the non-standard set-path information in set-path request packets
+@internalComponent
+*/
+NONSHARABLE_CLASS(TObexSetPathData) : public TObexData
+ {
+public:
+ TObexSetPathData ();
+protected:
+ // Implementation of TObexData functions
+ virtual TUint16 DoTotalSize () const; //< Total size of this data element
+ virtual TUint16 ParseIn (TUint8* aSource, const TUint16 aMaxSize);
+ virtual TUint16 WriteOut (TUint8* aDest, const TUint16 aMaxSize) const;
+public:
+ TUint8 iFlags;
+ TUint8 iConstants;
+ };
+
+#endif // __OBEXSETPATHDATA_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexsyncfilewriter.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,61 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __OBEXSYNCFILEWRITER_H__
+#define __OBEXSYNCFILEWRITER_H__
+
+#include <e32base.h>
+#include "obexfilewriter.h"
+
+class RFile;
+/**
+Obex Synchronous File Writer
+
+This object writes data from Obex objects to disk synchronously.
+
+Not intended for derivation.
+
+@internalComponent
+@released
+*/
+NONSHARABLE_CLASS(CObexSyncFileWriter) : public CBase, public MObexFileWriter
+ {
+public:
+ // Construction / destruction
+ static MObexFileWriter* NewL(RFile& aFile);
+ ~CObexSyncFileWriter();
+
+private:
+ // From MObexFileWriter
+ TInt Write(TInt aPos, CBufBase*& aBuf);
+ TInt FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength);
+
+private:
+ // Construction
+ void ConstructL();
+ CObexSyncFileWriter(RFile& aFile);
+
+// Unowned
+private:
+ /** Reference to the file which this object is used to write to */
+ RFile& iFile;
+ };
+
+#endif // __OBEXSYNCFILEWRITER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/inc/obexunderlyingheader.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,107 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef __OBEXUNDERLYINGHEADER_H
+#define __OBEXUNDERLYINGHEADER_H
+
+#include <obextypes.h>
+#include <obexheaders.h>
+
+/**
+Implements reference counting.
+
+@internalComponent
+*/
+NONSHARABLE_CLASS(CRefCounted) : public CBase
+ {
+public:
+ CRefCounted();
+ virtual ~CRefCounted();
+ void Open() const;
+ void Close() const;
+
+private:
+ mutable TInt iCount;
+ };
+
+/**
+Encapsulates an Obex header.
+
+This class provides the ability to hold a header of any of the Obex
+supported types as a native Symbian OS type.
+
+A header may also have one or more attributes set. These are used by
+the object which owns the header collection so that it can keep track
+of which headers should be sent (!(ESuppressed || EDeleted)), which have
+been sent (ESent), and whether the header should be deleted (EDeleted).
+
+This is a reference counted object and should not be used directly.
+Instead the CObexHeader object provides a facade which not only allows
+the CRefCounted nature of this class to be concealed, but also
+allows header objects to be deleted normally, which decrements the
+count. Ultimately the count will reach zero, at which point this header
+object will be destroyed.
+
+@see CObexBaseObject
+@see CObexHeader
+@internalComponent
+*/
+NONSHARABLE_CLASS(CObexUnderlyingHeader) : public CRefCounted
+ {
+public:
+ static CObexUnderlyingHeader* NewL();
+ virtual ~CObexUnderlyingHeader();
+
+ void ResetContents();
+ void SetAttributes(TUint16 aAttr);
+ TUint16 Attributes() const;
+
+ CObexHeader::THeaderType Type() const;
+
+ TUint8 HI() const;
+ TUint8 AsByte() const;
+ TUint32 AsFourByte() const;
+ const TDesC8& AsByteSeq() const;
+ const TDesC16& AsUnicode() const;
+
+ void SetByte(const TUint8 aHI, const TUint8 aByte);
+ void SetFourByte(const TUint8 aHI, const TUint32 aFourByte);
+ void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq);
+ void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode);
+
+ TInt EncodedSize() const;
+
+private:
+ CObexUnderlyingHeader();
+
+private:
+ TUint16 iAttributes;
+ TUint8 iHI;
+
+ union
+ {
+ TUint8 iByte;
+ TUint32 iFourByte;
+ HBufC8* iByteSeq;
+ HBufC16* iUnicode;
+ } iHV;
+ };
+
+#endif // __OBEXUNDERLYINGHEADER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/OBEX.H Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,34 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+ @released
+*/
+
+#ifndef OBEX_H
+#define OBEX_H
+
+#include <obextypes.h>
+#include <obexconstants.h>
+#include <obexbaseobject.h>
+#include <obexobjects.h>
+#include <obexheaders.h>
+#include <obexbase.h>
+#include <obexclient.h>
+#include <obexserver.h>
+
+#endif // OBEX_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/ObexBtTransportInfo.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,36 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXBTTRANSPORTINFO_H__
+#define __OBEXBTTRANSPORTINFO_H__
+
+#include <bt_sock.h>
+#include <obextransportinfo.h>
+
+/**
+Concrete transport info type for use when using RFCOMM transport controller.
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexBtTransportInfo) : public TObexTransportInfo
+ {
+public:
+ /**
+ The BT device address of the remote party.
+ */
+ TBTSockAddr iAddr;
+ };
+
+#endif // __OBEXBTTRANSPORTINFO_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/ObexIrTransportInfo.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,96 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXIRTRANSPORTINFO_H__
+#define __OBEXIRTRANSPORTINFO_H__
+
+#include <ir_sock.h>
+#include <obextransportinfo.h>
+
+/**
+Concrete transport info type for use when using Irda ttp transport controller.
+@see KObexIrTTPProtocol
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexIrTransportInfo) : public TObexTransportInfo
+
+ {
+//From TObexIrProtocolInfo
+public:
+ /** IrDA address information for this connection, as used in the IrDA sockets interface.
+ Refer to the SDK for more information about this.
+ Its main use is for setting the port that the local machine will listen on. */
+ TIrdaSockAddr iAddr;
+ /** The IAS class value that the OBEX session will register its listener port,
+ or request remote port with. */
+ TBuf8<KIASClassNameMax> iClassName;
+ /** The IAS attribute value that the OBEX session will register its listener port,
+ or request remote port with. */
+ TBuf8<KIASAttributeNameMax> iAttributeName;
+ };
+
+/**
+Concrete transport info type for use when using Irda ttp transport controller, with discovery extensions.
+@see KObexIrTTPProtocolV2
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexIrV2TransportInfo) : public TObexIrTransportInfo
+
+ {
+//From TObexIrProtocolInfo
+public:
+ /** The number of discovery slots to use. */
+ TUint8 iDiscoverySlots;
+ /** The number of discovery attempts to make. */
+ TUint8 iDiscoveryAttempts;
+
+private:
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // None of these padding variables have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ TUint32 iPadding3;
+ TUint32 iPadding4;
+ };
+
+
+/**
+Concrete transport info type for use when using Irda ttp transport controller, with nickname extension.
+@see KObexIrTTPProtocolV3
+@publishedAll
+
+@capability WriteDeviceData If the TObexIrV3TransportInfo is passed as the argument
+ to CObexServer::NewL or CObexClient::NewL and the associated
+ name is valid.
+
+@released
+*/
+NONSHARABLE_CLASS(TObexIrV3TransportInfo) : public TObexIrV2TransportInfo
+ {
+public:
+ /** The device nickname. The maximum length in the IrDA specification
+ is defined as 23 - (number of hint octets [2] + 1) = 20
+ */
+ TBuf<20> iLocalDeviceNickname;
+
+ /** A flag indicating if the device nickname field is valid. This
+ allows Symbian to make further derivations of this interface without making
+ the device nickname mandatory */
+ TBool iLocalDeviceNicknameValid;
+ };
+
+#endif // __OBEXIRTRANSPORTINFO_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/ObexTransportInfo.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,82 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXTRANSPORTINFO_H__
+#define __OBEXTRANSPORTINFO_H__
+
+#include <e32std.h>
+
+/**
+This class is a combination of the TObexProtocolInfo and TObexProtocolPolicy
+classes.
+This class is designed for licensee derivation, to support novel transport
+controllers. Existing superclasses include @c TObexUsbTransportInfo, @c
+TObexUsbV2TransportInfo, @c TObexBtTransportInfo and @c TObexIrTransportInfo.
+It is also designed for 3rd party instantiation, for use when creation a
+CObexServer or a CObexClient.
+
+Note that, being a T-type, this type and all derived types must hold data by
+value, to support bitwise copying.
+
+@publishedAll
+@released
+*/
+class TObexTransportInfo
+ {
+public:
+ /**
+ The type of the transport over which obex will run.
+ The size of the buffer is chosen for historical reasons. This is the size
+ originally used by TObexProtocolInfo.
+ @publishedAll
+ @released
+ */
+ TBuf<60> iTransportName;
+
+ /**
+ The version of the protocol policy format that this class supports
+ @publishedAll
+ @released
+ */
+ TUint16 iVersion;
+
+ /**
+ The maximum size of the receive packet buffer for the policy
+ @publishedAll
+ @released
+ */
+ TUint16 iReceiveMtu;
+
+ /**
+ The maximum size of the transmit packet buffer for the policy
+ @publishedAll
+ @released
+ */
+ TUint16 iTransmitMtu;
+
+ /** */
+ TUint16 iFuture1;
+
+ /** */
+ TUint32 iFuture2;
+
+ /** */
+ TInt iFuture3;
+
+ /** */
+ TInt iFuture4;
+ };
+
+#endif // __OBEXTRANSPORTINFO_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/ObexUsbTransportInfo.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,56 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXUSBTRANSPORTINFO_H__
+#define __OBEXUSBTRANSPORTINFO_H__
+
+#include "obextransportinfo.h"
+#include <obexconstants.h>
+
+/**
+Concrete transport info type for use when using the usb transport controller.
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexUsbTransportInfo) : public TObexTransportInfo
+ {
+//Data from TObexUsbProtocolInfo class, declared in obex\public\obexconstants.h
+public:
+ /** Provides a string to be attached to the Obex function's Communication Class interface,
+ which may be used to identify the Obex service. */
+ TBuf16<KUsbIntStringDescLength> iInterfaceStringDescriptor;
+ };
+
+/**
+Concrete transport info type when using the USB transport controller with client driver extensions.
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexUsbV2TransportInfo) : public TObexUsbTransportInfo
+ {
+
+ //Data from TObexUsbProtocolInfoV2 class, declared in obex\public\obexconstants.h
+public:
+ /** Bitmap containing the bandwidth priorities to use on IN and OUT endpoints
+ @see TUsbcBandwidthPriority
+ */
+ TInt iBandwidthPriority;
+ /** Specifies whether to use DMA on the bulk OUT endpoint */
+ TBool iDmaOnOutEndpoint;
+ /** Specifies whether to use DMA on the bulk IN endpoint */
+ TBool iDmaOnInEndpoint;
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexbase.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,236 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXBASE_H
+#define __OBEXBASE_H
+
+#include <obextypes.h>
+#include <mobexnotify.h>
+
+class CObexTransportControllerBase;
+class TObexTransportInfo;
+class CObexPacket;
+class CObexNotifyHandlerBase;
+
+/**
+@publishedAll
+@released
+
+This class is the common base class for any object which wishes
+to use the Obex Server or Client.
+The class which owns a CObexClient or CObexServer must be provide an object
+derived from this class to handle the call from the Server/Client for a request
+for a Password.
+@see CObex::SetCallBack
+*/
+class MObexAuthChallengeHandler
+ {
+public:
+ /**
+ Indicates that the server/client has received an Authentication challenge. The challenge
+ can only be responded to once a password has been retrieved by some means and passed
+ back to the calling class. The password is passed back via CObex::UserPasswordL
+ @param aRealm This will contain the Realm specified by the unit forcing the
+ Authentication, if no UserID was supplied then this parameter will be of zero length.
+ */
+ virtual void GetUserPasswordL(const TDesC& aRealm) = 0;
+
+ /**
+ Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
+ @param aInterface UID of the interface to return
+ @param aObject the container for another interface as specified by aInterface
+ */
+ IMPORT_C virtual void MOACH_ExtensionInterfaceL(TUid aInterface, void*& aObject);
+ };
+
+/**
+This class is the common base class for CObexClient and CObexServer. It is
+an abstract class and cannot be instantiated in itself. However, it does
+contain user functionality common to both client and server connections.
+
+Provides the basic OBEX transport functionality (sending and receiving
+files)
+Client and server provide the more specialied APIs for
+- initiation or response to puts & gets
+- (possible) handling of more generalised 'objects' (prob. with data buffered through a file).
+
+This class is not designed for user derivation
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObex) : public CBase, protected MObexNotify
+ {
+public:
+ /**
+ Describes the information set or received in a SETPATH command.
+
+ The first bit of iFlags, 0, can be set to indicate to the receiver of SETPATH to backup a level before applying the path name.
+ The second bit of iFlags, 1, can be set to indicate to the receiver of SETPATH to NOT create the directory if it doesn't exist.
+ The iConstants variable is always set to zero as it is reserved.
+ The iName variable indicates the directory to create or go to, and does not include the root directory of the receiver (i.e.
+ if the directory to be set is C:\notes then iName is set to "notes").
+ If a name is not set then set CObex::TSetPathInfo::iNamePresent to false.
+ */
+ NONSHARABLE_CLASS(TSetPathInfo)
+ {
+ public:
+ IMPORT_C TSetPathInfo();
+ TSetPathInfo(const TObexSetPathData& aData);
+ IMPORT_C TBool Parent() const;
+ TUint8 iFlags;
+ TUint8 iConstants;
+ TBuf<KObexObjectDescriptionSize> iName;
+ /** Whether iName is present in this SETPATH info */
+ TBool iNamePresent;
+ private:
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+ /**
+ Current obex connection state
+ In general, the further through the enum the values are,
+ the further through the connection process the state machine
+ will be.
+ */
+ enum TConnectState
+ {
+ EConnIdle, /** Nothing is happening */
+ EConnTransport, /** Transport Link connected not yet established true Link */
+ EConnObex, /** full connection established */
+ ESimpleConnRequest, /** Connect without Auth has been sent by ClientReceived by Server */
+ EConnChallRxed, /** Server has issued a challenge, to a Client cionnect */
+ ESimpleConnChallIssued, /** Server, received Simple Connect but Server Challenge issued */
+ EChallConnRequested, /** Connect with Auth has been sent by Client/Received by Server */
+ EChallConnChallIssued, /** Server has sent a Challenge & Resp to a Client EChallConnRequest */
+ EWaitForFinalResponse, /** Client, waiting for final success/fail not chall-response expected
+ Server, Waiting for final Resp fromm Client to Challenge */
+ EFinalResponseReceived, /** Server, the final response has been received */
+ EFinalChallRxed, /** Server, Client connect with challenge, Server responds with challenge, Client re-issued original/new challenge */
+ EWaitForUserInput, /** waiting for the user */
+ EDropLink /** drop the link */
+ };
+
+ /**
+ The Obex operation currently being performed.
+ */
+ enum TOperation
+ {
+ EOpConnect = 0x00, /** Connect */
+ EOpDisconnect = 0x01, /** Disconnect */
+ EOpPut = 0x02, /** Put */
+ EOpGet = 0x03, /** Get */
+ EOpSetPath = 0x05, /** SetPath */
+ EOpAbort = 0xFF, /** Abort - must fit in one pkt so final bit is always set */
+ EOpAbortNoFBit = 0x7F, /** Abort (internal, never transmitted) */
+ EOpGetResponse = 0xFD, /** Internal - not actually an obex operation. */
+ EOpIdle = 0xFE, /** Internal - not actually an obex operation. */
+ };
+
+ /**
+ Flags to suppress the authentication elements of the authentication challenge header.
+ */
+ enum TObexSuppressedAuthElements
+ {
+ EObexNoSuppressedAuthElements = 0x00,
+ EObexSuppressChallengeOptionsAuthElement = 0x01,
+ EObexSuppressRealmAuthElement = 0x02,
+ EObexSuppressAllAuthElements = EObexSuppressChallengeOptionsAuthElement | EObexSuppressRealmAuthElement // Must be last
+ };
+
+ virtual ~CObex();
+ IMPORT_C void SetCallBack(MObexAuthChallengeHandler& aCallBack);
+ IMPORT_C TBool IsConnected() const;
+ IMPORT_C TBool IsStrictPeer() const;
+ IMPORT_C const TObexConnectInfo& LocalInfo() const;
+ IMPORT_C TInt SetLocalWho(const TDesC8& aInfo);
+ IMPORT_C const TObexConnectInfo& RemoteInfo() const;
+ IMPORT_C void SuppressAuthenticationHeaderElements(TObexSuppressedAuthElements aSuppressedObexAuthElements);
+
+public: // Implementation of MObexNotify Interface (No longer used)
+ virtual void Process(CObexPacket& aPacket);
+ virtual void Error(TInt aError);
+ virtual void TransportUp();
+ virtual void TransportDown(TBool aForceTransportDeletion);
+
+public:
+ virtual void UserPasswordL( const TDesC& aPassword) = 0;
+ IMPORT_C void RemoteAddr(TSockAddr& anAddr);
+
+ TConnectState GetConnectState() const;
+
+ IMPORT_C TBool IsAuthenticating() const;
+
+ // Handling notified events.
+ void NotifyProcess(CObexPacket& aPacket);
+ void NotifyError(TInt aError);
+ void NotifyTransportUp();
+ void NotifyTransportDown(TBool);
+
+protected:
+ CObex();
+ virtual void ConstructL(TObexTransportInfo& aObexTransportInfo);
+ virtual TInt ParseConnectPacket(CObexPacket& aPacket) = 0;
+ void SetConnectState(TConnectState aNewState);
+ IMPORT_C TConnectState ConnectState() const; // same as GetConnectState - has to be maintained here for BC
+ virtual void OnPacketReceive(CObexPacket& aPacket) =0;
+ virtual void OnError(TInt aError) =0;
+ virtual void OnTransportUp() =0;
+ virtual void OnTransportDown() =0;
+ void ProcessChallengeL(const TObexInternalHeader& hdr); //process the received challenge
+ void ProcessChallResponseL(const TObexInternalHeader& hdr); //process the response to challenge
+ TInt GenerateChallenge(CObexPacket& aPacket); //generate a challenge
+ void PrepareChallResponseL(const TDesC& aPassword); //generate a response to challenge
+ //after user Password input
+ void ForcedTransportDown();
+ void ControlledTransportDown();
+ void RemoteInfoCleanup();
+ void CancelObexConnection();
+protected:
+ TConnectState iConnectState;
+ CObexTransportControllerBase* iTransportController;
+ TObexConnectInfo iLocalInfo;
+ TObexConnectInfo iRemoteInfo;
+ MObexAuthChallengeHandler* iCallBack;
+ TNonce iOutgoingNonce; //nonce used when challenging
+ TNonce iIncomingNonce; //nonce used when receiving a challenge
+ HBufC8* iChallPassword; //password used when challenging
+ HBufC8* iRespPassword; //password used when responding to a challenge
+ HBufC8* iRxChallenge;
+ TBuf8<KChallResponseSize> iOutgoingChallResp;//response to the previously issued challenge
+ //16 nonce, 16 digest resp, 20 UserID, 3*(tag+size)
+ TBuf8<KChallResponseSize> iIncomingChallResp;//response received from previous challenge
+ TBuf8<KObexRespSize> iIncomingRequestDigest;
+ HBufC* iRemoteUID; //UID of remote device
+ HBufC* iRemoteRealm;//Realm of remote device
+ CObexAuthenticator* iAuthEngine;
+ TBool iChallenge; //to challenge or not to challenge?
+ TBool iUserIDRequested; //does the challenge insist that a UserID is returned
+ TBool iReserved; //released boolean now available for future use
+ TOperation iCurrentOperation;
+ CObexNotifyHandlerBase* iNotifyHandler;
+ TUint iSuppressedObexAuthElements;
+ };
+
+#endif // __OBEXBASE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexbaseobject.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,145 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXBASEOBJECT_H
+#define __OBEXBASEOBJECT_H
+
+#include <obextypes.h>
+#include <f32file.h>
+
+const TUint32 KConnIDInvalid = 0xffffffff;
+
+/**
+Objects of this class are used to describe the objects to be transferred and
+those received via Obex.
+Consists of a number of attributes describing the object, along with
+methods to set them. CObexBaseObject is an abstract base class, which defines
+attribute setting and transferring functionality, but does not specify the
+storage mechanism for the data part (called the object body) of the object.
+This body part is defined in derived classes.
+
+Object description attributes are tracked for validity automatically, so
+that only valid attributes are sent to the remote machine. Also has the
+concept of "header masks". This selects which of the various attributes
+will actually be sent out/read in when the object is used in an operation
+with the remote machine. Objects default to transferring all valid
+attributes, use the header mask if restriction is required on the headers
+exchanged.
+
+See the various derived classes for description of object body
+representation.
+
+The common attributes are defined to be as close to the underlying OBEX
+headers as usefully possible, hence any OBEX header specified as a Unicode
+string (e.g. Name) translate to TDes (variant) EPOC descriptors, "byte
+sequences" (e.g. Type) are TDes8 (or ASCII invariant), and byte and 32 bit
+integers (e.g. Length) are TUint32s.
+
+This class is not designed for user derivation (ie. outside of this dll).
+
+@see CObexHeader
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexBaseObject) : public CBase
+ {
+// required for access to iValidHeaders in CObexServer::CheckForConnectionID
+friend class CObexServer;
+
+public:
+ virtual ~CObexBaseObject();
+ IMPORT_C void SetHeaderMask(const TObexHeaderMask aHeaderMask);
+ IMPORT_C void SetNameL(const TDesC& aDesc);
+ IMPORT_C void SetTypeL(const TDesC8& aDesc);
+ IMPORT_C void SetLengthL(const TUint32 aLength);
+ IMPORT_C void SetTimeL(const TTime aLocalTime);
+ IMPORT_C void SetDescriptionL(const TDesC& aDesc);
+ IMPORT_C void SetTargetL(const TDesC8& aDesc);
+ IMPORT_C void AddHttpL(const TDesC8& aDesc);
+ IMPORT_C void SetAppParamL(const TDesC8& aDesc);
+
+ IMPORT_C void AddHeaderL(CObexHeader& aHeader);
+ IMPORT_C TInt BytesSent();
+ IMPORT_C TInt BytesReceived();
+ IMPORT_C TObexHeaderMask HeaderMask();
+ IMPORT_C TObexHeaderMask ValidHeaders();
+ IMPORT_C const TDesC& Name();
+ IMPORT_C const TDesC8& Type();
+ IMPORT_C TUint32 Length();
+ IMPORT_C const TTime Time();
+ IMPORT_C const TDesC& Description();
+ IMPORT_C const TDesC8& Target();
+ IMPORT_C const RPointerArray<HBufC8>* Http() const;
+ IMPORT_C const TDesC8& AppParam() const;
+ IMPORT_C void Reset();
+ IMPORT_C const CObexHeaderSet& HeaderSet() const;
+ IMPORT_C CObexHeaderSet& HeaderSet();
+
+ // Public unexported functions used by CObexServer, CObexClient, etc
+ enum TProgress { EContinue,EComplete,EError,ELastPacket };
+ TInt InitSend(TObexOpcode aOpcode);
+ TProgress PrepareNextSendPacket(CObexPacket& aPacket);
+ TInt InitReceive();
+ TProgress ParseNextReceivePacket(CObexPacket& aPacket);
+ void PrepareConnectionHeader( CObexPacket& aPacket );
+ void SetConnectionIdL(TUint32 aFourByte);
+ TUint32 ConnectionID();
+ TObexResponse GetLastError() const;
+
+protected:
+ CObexBaseObject();
+ void GuessTypeFromExtL(const TDesC& aExt);
+ void ResetHeaders();
+ // Pure virtuals that all derived objects must implement
+ virtual void GetData(TInt aPos, TDes8& aDes) =0;
+ virtual void NewData(TInt aPos, TDes8& aDes) =0;
+ virtual TInt DataSize() =0;
+ virtual void ResetData() =0;
+ void CreateHeaderStorageDataL();
+ void SetTimeHeaderL(const TDesC8& aTimeDes);
+ void SetUtcTimeL(const TTime aUtcTime);
+
+// Data
+private:
+ TObexHeaderMask iHeaderMask;
+ TObexHeaderMask iValidHeaders;
+
+ mutable RPointerArray<HBufC8>* iHttp;
+
+ CObexHeaderSet* iHeaderSet;
+
+ TProgress iSendProgress;
+ TProgress iRecvProgress;
+ TObexOpcode iSendOpcode;
+
+ // This data item is used to store a CObexHeader which is used as a temporary
+ // store when finding headers
+ CObexHeader* iObexHeader;
+
+ TObexHeaderMask iSendHeaders;
+ TInt iSendBytes;
+ TInt iRecvBytes;
+
+ TObexResponse iLastError;
+
+ };
+
+#endif // __OBEXBASEOBJECT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexclient.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,108 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXCLIENT_H
+#define __OBEXCLIENT_H
+
+#include <obextypes.h>
+#include <obexbase.h>
+
+class CObexPacket;
+class MObexFinalPacketObserver;
+class CObexPacketSignaller;
+class CObexPacketTimer;
+class CObexErrorEngine;
+
+/**
+Client side functionality. Connection based.
+Supports ...
+- Opening IrDA TTP sockets for the OBEX session.
+- Opening an OBEX session over a connected socket
+- Standard OBEX (spec. version 1.2) operations.
+
+This class is not designed for user derivation.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexClient) : public CObex
+ {
+public:
+ IMPORT_C ~CObexClient();
+ IMPORT_C static CObexClient* NewL(TObexProtocolInfo& aObexProtocolInfoPtr);
+ IMPORT_C static CObexClient* NewL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy);
+ IMPORT_C static CObexClient* NewL(TObexTransportInfo& aObexTransportInfo);
+ IMPORT_C void Connect(TRequestStatus& aStatus);
+ IMPORT_C void Connect(CObexBaseObject& aObject, TRequestStatus& aStatus);
+ IMPORT_C void ConnectL(CObexBaseObject& aObject, const TDesC& aPassword, TRequestStatus& aStatus);
+ IMPORT_C void ConnectL(const TDesC& aPassword, TRequestStatus& aStatus);
+ IMPORT_C void Disconnect(TRequestStatus& aStatus);
+ IMPORT_C void Put(CObexBaseObject& aObject, TRequestStatus& aStatus);
+ IMPORT_C void Get(CObexBaseObject& aObject, TRequestStatus& aStatus);
+ IMPORT_C void SetPath(TSetPathInfo& aPathInfo, TRequestStatus& aStatus);
+ IMPORT_C void Abort();
+ IMPORT_C void UserPasswordL( const TDesC& aPassword);
+ IMPORT_C const CObexHeaderSet& GetPutFinalResponseHeaders();
+ IMPORT_C void SetFinalPacketObserver(MObexFinalPacketObserver* aObserver);
+ IMPORT_C TObexResponse LastServerResponseCode() const;
+ IMPORT_C void SetCommandTimeOut(TTimeIntervalMicroSeconds32 aTimeOut);
+ IMPORT_C TAny* ExtensionInterface(TUid aUid);
+
+public: // Called from CObexNotifyExtendClient
+ void SignalPacketProcessEvent(TInt aEvent);
+ void TimeOutCompletion();
+
+private:
+ CObexClient();
+ void ConstructL(TObexTransportInfo& aObexTransportInfo);
+ TBool AlreadyActive(TRequestStatus& aStatus);
+ void ClientCommandL(TOperation aOp, TAny* aParam, TRequestStatus& aStatus);
+ // Implementation of CObex Events
+ virtual void OnPacketReceive(CObexPacket& aPacket);
+ virtual void OnError(TInt aError);
+ virtual void OnTransportUp();
+ virtual void OnTransportDown();
+ void SetRequest(TRequestStatus& aStatus, TOperation aOperation);
+ void CompleteRequest(const TInt aCompletion);
+ TInt PrepareConnectPacket(CObexPacket& aPacket); // Should be members of TConnectInfo
+ TInt ParseConnectPacket(CObexPacket& aPacket);
+ void ResetConnectionID();
+ void SetConnectionID(TUint32 aConnectionID);
+ void EmptyHeaderSet();
+ void SendRequestPacket();
+ void SendRequestPacket(TObexOpcode aObexOpcode);
+
+private:
+ TRequestStatus* iPendingRequest;
+ CObexBaseObject* iCurrentObject;
+ TUint32 iConnectionID;
+ TBool iConnectionIdSet;
+ CObexHeaderSet* iHeaderSet;
+ CObexHeader* iHeader;
+ CObexPacketSignaller* iPacketProcessSignaller;
+ TObexResponse iLastReceivedResponseOpcode;
+ CObexErrorEngine* iErrorEngine;
+ TBool iIsLastErrorSet;
+ TTimeIntervalMicroSeconds32 iCmdTimeOutDuration;
+ CObexPacketTimer* iPacketTimer;
+ };
+
+#endif // __OBEXCLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexconstants.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,595 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXCONSTANTS_H
+#define __OBEXCONSTANTS_H
+
+#include <e32std.h>
+#include <es_sock.h>
+#include <ir_sock.h>
+#include <bt_sock.h>
+#include <obexpanics.h>
+#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <obexconstantsinternal.h>
+#endif
+
+
+/** @publishedAll */
+const TInt KChallResponseSize = 58;
+/** @publishedAll */
+const TInt KObexRespSize = 16;
+/** @publishedAll */
+const TInt KUsbIntStringDescLength = 30;
+/** @publishedAll */
+const TUint8 KObexObjectDescriptionSize = 255;
+
+// Extended errors for IrObex
+
+/** Must not use as not in the allocated range */
+const TInt KErrIrObexRespBase = - 5500;
+
+/** Extended error for IrObex - No other infrared device found */
+const TInt KErrIrObexClientNoDevicesFound = -5501;
+
+/** Extended error for IrObex - Other IR device cannot handle IrObex */
+const TInt KErrIrObexClientPeerDoesNotHaveObex = -5502;
+
+/** Extended error for IrObex - Other IR device aborted the transfer */
+const TInt KErrIrObexClientPutPeerAborted = -5503;
+
+/** Extended error for IrObex - Peer device aborted data transmission/obex sending */
+const TInt KErrIrObexServerPutPeerAborted = -5507;
+
+/** Extended error for IrObex - Cannot authorise the challenge so link dropped */
+const TInt KErrIrObexConnectChallRejected = -5512;
+
+// Other Obex errors defined in the system but no longer used
+// Do not reuse the number!
+// KErrIrObexClientPutPeerCannotHandleObject -5504
+// KErrIrObexServerPutFileWriteError -5509
+// KErrIrObexClientFirstPutFailed -5510
+// KErrIrObexClientSubsequentPutFailed -5511
+
+/** Unexpected event for the given state */
+const TInt KErrIrObexBadEvent = -5513;
+
+/** Event occurred while Server is stopped */
+const TInt KErrIrObexServerStopped = -5514;
+
+/** Packet received while state machine is in a wait state */
+const TInt KErrIrObexPacketDuringWait = -5515;
+
+// There are other error codes defined at the end of this file,
+// which are a direct mapping of specific Obex error codes and
+// are returned by the client.
+
+
+// Flags used by Connect
+// ...None in OBEX 1.0
+
+
+/**
+Version number for TObexTransportInfo and derived classes.
+When iVersion is set to this value the following fields of TObexTransportInfo
+must be set:
+iTransportName,
+iReceiveMtu
+iTransmitMtu
+The iVersion member variable must be set to this value. If in future any of the
+iFuture variables are used a new version constant will be created.
+
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+const TInt KObexTransportInfoVersion0 = 0;
+
+/**
+Default for the receive and transmit MTU sizes
+Use this default value for setting the iReceiveMtu or iTransmitMtu in TObexTransportInfo
+objects or derived classes.
+
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+const TInt KObexDefaultMtuSize = 4000;
+
+/**
+Default value for the number of discovery slots to use. Use this value as a default
+for iDiscoverySlots in TObexIrdaV2TransportInfo.
+
+@see TObexIrdaV2TransportInfo
+@publishedAll
+@released
+*/
+const TUint KObexIrdaDefaultDiscoverySlotsToUse = 1;
+
+/**
+Default value for the number of discovery attempts made. Use this value as a default for iDiscoveryAttempts
+in TObexIrdaV2TransportInfo.
+@see TObexIrdaV2TransportInfo
+@publishedAll
+@released
+*/
+const TUint KObexIrdaDefaultDiscoveryAttempts = 4;
+
+// Constants used to define which transport Obex will run over.
+// Used in TObexTransportInfo and TObexProtocolInfo's iTransport member.
+
+/**
+Protocol string when running over IrDA
+@see TObexIrProtocolInfo
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexIrTTPProtocol, "IrTinyTP");
+
+/**
+Protocol string when running over IrDA
+Using this version indicates that the configuration object contains discovery parameters.
+@see TObexIrProtocolInfo
+@publishedAll
+@released
+*/
+_LIT(KObexIrTTPProtocolV2, "IrTinyTP-V2");
+
+/**
+Protocol string when running over IrDA
+Using this version indicates that the configuration object contains the device nickname.
+@see TObexIrProtocolInfo
+@publishedAll
+
+@capability WriteDeviceData If the TObexIrV3TransportInfo is passed as the argument
+ to CObexServer::NewL or CObexClient::NewL and the associated
+ name is valid.
+@released
+*/
+_LIT(KObexIrTTPProtocolV3, "IrTinyTP-V3");
+
+/**
+Protocol string when running over Bluetooth
+@see TObexBluetoothProtocolInfo
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexRfcommProtocol, "RFCOMM");
+
+/**
+Protocol string when running over USB
+@see TObexUsbProtocolInfo
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexUsbProtocol, "USB");
+
+/**
+Place holder for...
+protocol string that should be used
+if a Win32 emulator USB transport were
+to be created for testing.
+@see TObexUsbProtocolInfo
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexWin32UsbProtocol, "Win32Usb");
+
+/**
+Protocol string when running over USB using client driver extensions
+@see TObexUsbProtocolInfoV2
+@see TObexTransportInfo
+@publishedAll
+@released
+*/
+_LIT(KObexUsbProtocolV2, "USB-V2");
+
+/**
+This class is derived for each underlying transport protocol OBEX
+runs over.
+
+The iTransport member holds the unique name for the transport. For example for
+infra-red (TinyTP) this is "IrTinyTP" or KObexIrTTPProtocol.
+
+@see TObexIrProtocolInfo for running over TinyTP
+@see TObexBluetoothProtocolInfo for running over Rfcomm
+@see TObexUsbProtocolInfo for running over USB
+@see TObexUsbProtocolInfoV2 for running over USB using client driver extensions
+
+@see KObexIrTTPProtocol
+@see KObexIrTTPProtocolV2
+@see KObexRfcommProtocol
+@see KObexUsbProtocol
+@see KObexUsbProtocolV2
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexProtocolInfo)
+ {
+public:
+ /** Holds the unique name for the transport. */
+ TBuf<60> iTransport;
+private:
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+/**
+Used to describe IrDA specific protocol information
+
+To access the default OBEX server, the IAS class value should be "OBEX"
+and the IAS attribute name "IrDA:TinyTP:LsapSel".
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexIrProtocolInfo) : public TObexProtocolInfo
+ {
+public:
+ /** IrDA address information for this connection, as used in the IrDA sockets interface.
+ Refer to the SDK for more information about this.
+ Its main use is for setting the port that the local machine will listen on. */
+ TIrdaSockAddr iAddr;
+ /** The IAS class value that the OBEX session will register its listener port,
+ or request remote port with. */
+ TBuf8<KIASClassNameMax> iClassName;
+ /** The IAS attribute value that the OBEX session will register its listener port,
+ or request remote port with. */
+ TBuf8<KIASAttributeNameMax> iAttributeName;
+ /** The number of discovery slots to use. */
+ TUint8 iDiscoverySlots;
+ /** The number of discovery attempts to make. */
+ TUint8 iDiscoveryAttempts;
+
+private:
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // None of these padding variables have been zero'd because they are currently not used
+ TUint16 iPadding1;
+ TUint32 iPadding2;
+ TUint32 iPadding3;
+ TUint32 iPadding4;
+ };
+
+/**
+Used to describe Bluetooth specific protocol information
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexBluetoothProtocolInfo) : public TObexProtocolInfo
+ {
+public:
+ /**
+ For OBEX servers:
+ This defines the server channel on which the OBEX server listens
+ for connections. The server channel is set using SetPort on the
+ TRfcommSockAddr.
+ Note:
+ 1) Unless the channel is defined as KRfcommPassiveAutoBind
+ it may be in use when the obex server attempts to 'bind' to it
+ 2) If the channel is defined as KRfcommPassiveAutoBind
+ then when the server is FIRST started it will attempt
+ to find a free RFComm channel. If this is successful
+ that free channel will be used as the server channel
+ for the life time of the obex server including
+ when it is 'stopped' and re-'started'.
+ 3) When the obex server is stopped, and very
+ briefly when a bluetooth connection comes down, the
+ obex server releases its server channel. It is possible
+ therefore that during this time another application might bind
+ to it. This will cause an error when the obex server tries
+ to re-bind.
+
+ Also note that a Bluetooth OBEX server will itself set the Object Transfer
+ bit in the Service Class as required by the Generic Object Exchange
+ Profile so the user need not do this.
+ @see CObexServer
+
+ For OBEX clients:
+ This defines the server channel and the
+ device address to connect to. The server channel
+ and device address are set respectively using SetPort
+ and SetBTAddr on the TRfcommSockAddr.
+ */
+ TRfcommSockAddr iAddr;
+
+private:
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+/**
+Used to describe USB specific protocol information
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexUsbProtocolInfo) : public TObexProtocolInfo
+ {
+public:
+ /** Provides a string to be attached to the Obex function's Communication Class interface,
+ which may be used to identify the Obex service. */
+ TBuf16<KUsbIntStringDescLength> iInterfaceStringDescriptor;
+ };
+
+/**
+Used to set options used by the extended USB client driver for improved performance
+
+@see TObexUsbProtocolInfo
+@see RDevUsbcClient
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexUsbProtocolInfoV2) : public TObexUsbProtocolInfo
+ {
+public:
+ /** Bitmap containing the bandwidth priorities to use on IN and OUT endpoints
+ @see TUsbcBandwidthPriority
+ */
+ TInt iBandwidthPriority;
+ /** Specifies whether to use DMA on the bulk OUT endpoint */
+ TBool iDmaOnOutEndpoint;
+ /** Specifies whether to use DMA on the bulk IN endpoint */
+ TBool iDmaOnInEndpoint;
+
+private:
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // None of these padding variables have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ TUint32 iPadding3;
+ TUint32 iPadding4;
+ };
+
+/**
+Contains information about OBEX packet sizing policy, defining the
+maximum buffer size for receive and transmit packets
+*/
+NONSHARABLE_CLASS(TObexProtocolPolicy)
+ {
+public:
+ IMPORT_C TObexProtocolPolicy (); // Sets version and default values
+
+ IMPORT_C TInt SetReceiveMtu ( TUint16 aReceiveMtu );
+ IMPORT_C TInt SetTransmitMtu ( TUint16 aTransmitMtu );
+ IMPORT_C TUint16 Version () const;
+ IMPORT_C TUint16 ReceiveMtu () const;
+ IMPORT_C TUint16 TransmitMtu () const;
+
+private:
+ TUint16 iVersion;
+ TUint16 iReceiveMtu;
+ TUint16 iTransmitMtu;
+
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // None of these padding variables have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ TUint32 iPadding3;
+ TUint32 iPadding4;
+ };
+
+struct TObexConnectionInfo;
+
+/**
+TObexConnectInfo
+This structure contains information used during OBEX connection. iVersion
+holds the encoded OBEX version of the machine, use @c VersionMajor() and
+@c VersionMinor() to extract the parts of the version number (each having a
+value from 0 to 15). @c iFlags holds OBEX connection flags. @c iWho holds
+the Who attribute from the connect packet, if any was specified, or
+otherwise has a length of 0.
+It is recommended that this class is only ever allocated on the heap as it is quite big.
+*/
+NONSHARABLE_CLASS(TObexConnectInfo)
+ {
+public:
+ IMPORT_C TObexConnectInfo();
+ IMPORT_C TUint8 VersionMajor() const;
+ IMPORT_C TUint8 VersionMinor() const;
+public:
+ TUint8 iVersion; /** Encoded OBEX version of the machine*/
+ TUint8 iFlags; /** iFlags holds OBEX connection flags*/
+ TBuf8<KObexObjectDescriptionSize> iWho; /** the Who attribute from the connect packet, if any was specified */
+ TBuf8<KObexObjectDescriptionSize> iTargetHeader; /** the Target header from the connect packet, if any was specified */
+
+private:
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+
+
+//if these codes are extended due to a IRObex spec update ensure
+//that the TInt immediately below are updated
+//and the default in the method IrOBEXUtil::ObexResponse is also updated
+enum TObexResponse
+ {
+/** Response is "Continue" */
+ ERespContinue = 0x10,
+
+/** Response is "Success" */
+ ERespSuccess = 0x20,
+
+/** Response is "Created" */
+ ERespCreated = 0x21,
+
+/** Response is "Accepted" */
+ ERespAccepted = 0x22,
+
+/** Response is "Non-Authenticated Information" */
+ ERespNonAuthInfo = 0x23,
+
+/** Response is "No Content" */
+ ERespNoContent = 0x24,
+
+/** Response is "Reset Content" */
+ ERespResetContent = 0x25,
+
+/** Response is "Partial Content" */
+ ERespPartialContent = 0x26,
+
+/** Response is "Multiple Choices" */
+ ERespMultipleChoices = 0x30,
+
+/** Response is "Moved Permanently" */
+ ERespMovedPerm = 0x31,
+
+/** Response is "Moved Temporarily" */
+ ERespMovedTemp = 0x32,
+
+/** Response is "See Other" */
+ ERespSeeOther = 0x33,
+
+/** Response is "Not Modified" */
+ ERespNotModified = 0x34,
+
+/** Response is "Use Proxy" */
+ ERespUseProxy = 0x35,
+
+/** Response is "Bad Request" */
+ ERespBadRequest = 0x40,
+
+/** Response is "Unauthorized" */
+ ERespUnauthorized = 0x41,
+
+/** Response is "Payment Required" */
+ ERespPaymentRequired = 0x42,
+
+/** Response is "Forbidden" */
+ ERespForbidden = 0x43,
+
+/** Response is "Not Found" */
+ ERespNotFound = 0x44,
+
+/** Response is "Method Not Allowed" */
+ ERespMethodNotAllowed = 0x45,
+
+/** Response is "Not Acceptable" */
+ ERespNotAcceptable = 0x46,
+
+/** Response is "Proxy Authentication is Required" */
+ ERespProxyAuthenReqd = 0x47,
+
+/** Response is "Timed Out" */
+ ERespTimedOut = 0x48,
+
+/** Response is "Conflict" */
+ ERespConflict = 0x49,
+
+/** Response is "Gone" */
+ ERespGone = 0x4A,
+
+/** Response is "Length Required" */
+ ERespLengthReqd = 0x4B,
+
+/** Response is "Precondition Failed" */
+ ERespPreCondFailed = 0x4C,
+
+/** Response is "Required Entity is Too Large" */
+ ERespReqEntityTooLarge = 0x4D,
+
+/** Response is "Required URL is Too Large" */
+ ERespReqURLTooLarge = 0x4E,
+
+/** Response is "Unsupported Media Type" */
+ ERespUnsupMediaType = 0x4F,
+
+/** Response is "Internal Error" */
+ ERespInternalError = 0x50,
+
+/** Response is "Not Implemented" */
+ ERespNotImplemented = 0x51,
+
+/** Response is "Bad Gateway" */
+ ERespBadGateway = 0x52,
+
+/** Response is "Service Unavailable" */
+ ERespServiceUnavail = 0x53,
+
+/** Response is "Gateway Timeout" */
+ ERespGatewayTimeout = 0x54,
+
+/** Response is "HTTP Version is Not Supported" */
+ ERespHTTPVerNotSupp = 0x55,
+
+/** Response is "Database is Full" */
+ ERespDatabaseFull = 0x60,
+
+/** Response is "Database is Locked" */
+ ERespDatabaseLocked = 0x61,
+
+/** Response is "Service is Unavailable" */
+ ERespServiceUnavailable = 0xD3,
+ };
+
+
+//some error codes to be used specifically by the client
+//these shall, be mapped directly to OBEX defined error codes.
+const TInt KErrIrObexRespSuccess = KErrIrObexRespBase - ERespSuccess; //-5532 returns 0x20 (0xA0)
+const TInt KErrIrObexRespCreated = KErrIrObexRespBase - ERespCreated; //-5533 returns 0x21 (0xA1)
+const TInt KErrIrObexRespAccepted = KErrIrObexRespBase - ERespAccepted; //-5534 returns 0x22 (0xA2)
+const TInt KErrIrObexRespNonAuthInfo = KErrIrObexRespBase - ERespNonAuthInfo; //-5535 returns 0x23 (0xA3)
+const TInt KErrIrObexRespNoContent = KErrIrObexRespBase - ERespNoContent; //-5536 returns 0x24 (0xA4)
+const TInt KErrIrObexRespResetContent = KErrIrObexRespBase - ERespResetContent; //-5537 returns 0x25 (0xA5)
+const TInt KErrIrObexRespPartialContent = KErrIrObexRespBase - ERespPartialContent; //-5538 returns 0x26 (0xA6)
+const TInt KErrIrObexRespMultipleChoices = KErrIrObexRespBase - ERespMultipleChoices; //-5548 returns 0x30 (0xB0)
+const TInt KErrIrObexRespMovedPerm = KErrIrObexRespBase - ERespMovedPerm; //-5549 returns 0x31 (0xB1)
+const TInt KErrIrObexRespMovedTemp = KErrIrObexRespBase - ERespMovedTemp; //-5550 returns 0x32 (0xB2)
+const TInt KErrIrObexRespSeeOther = KErrIrObexRespBase - ERespSeeOther; //-5551 returns 0x33 (0xB3)
+const TInt KErrIrObexRespNotModified = KErrIrObexRespBase - ERespNotModified; //-5552 returns 0x34 (0xB4)
+const TInt KErrIrObexRespUseProxy = KErrIrObexRespBase - ERespUseProxy; //-5553 returns 0x35 (0xB5)
+const TInt KErrIrObexRespBadRequest = KErrIrObexRespBase - ERespBadRequest; //-5564 returns 0x40 (0xC0)
+const TInt KErrIrObexRespUnauthorized = KErrIrObexRespBase - ERespUnauthorized; //-5565 returns 0x41 (0xC1)
+const TInt KErrIrObexRespPaymentRequired = KErrIrObexRespBase - ERespPaymentRequired; //-5566 returns 0x42 (0xC2)
+const TInt KErrIrObexRespForbidden = KErrIrObexRespBase - ERespForbidden; //-5567 returns 0x43 (0xC3)
+const TInt KErrIrObexRespNotFound = KErrIrObexRespBase - ERespNotFound; //-5568 returns 0x44 (0xC4)
+const TInt KErrIrObexRespMethodNotAllowed = KErrIrObexRespBase - ERespMethodNotAllowed; //-5569 returns 0x45 (0xC5)
+const TInt KErrIrObexRespNotAcceptable = KErrIrObexRespBase - ERespNotAcceptable; //-5570 returns 0x46 (0xC6)
+const TInt KErrIrObexRespProxyAuthenReqd = KErrIrObexRespBase - ERespProxyAuthenReqd; //-5571 returns 0x47 (0xC7)
+const TInt KErrIrObexRespTimedOut = KErrIrObexRespBase - ERespTimedOut; //-5572 returns 0x48 (0xC8)
+const TInt KErrIrObexRespConflict = KErrIrObexRespBase - ERespConflict; //-5573 returns 0x49 (0xC9)
+const TInt KErrIrObexRespGone = KErrIrObexRespBase - ERespGone; //-5574 returns 0x4A (0xCA)
+const TInt KErrIrObexRespLengthReqd = KErrIrObexRespBase - ERespLengthReqd; //-5575 returns 0x4B (0xCB)
+const TInt KErrIrObexRespPreCondFailed = KErrIrObexRespBase - ERespPreCondFailed; //-5576 returns 0x4C (0xCC)
+const TInt KErrIrObexRespReqEntityTooLarge = KErrIrObexRespBase - ERespReqEntityTooLarge;//-5577 returns 0x4D (0xCD)
+const TInt KErrIrObexRespReqURLTooLarge = KErrIrObexRespBase - ERespReqURLTooLarge; //-5578 returns 0x4E (0xCE)
+const TInt KErrIrObexRespUnsupMediaType = KErrIrObexRespBase - ERespUnsupMediaType; //-5579 returns 0x4F (0xCF)
+const TInt KErrIrObexRespInternalError = KErrIrObexRespBase - ERespInternalError; //-5580 returns 0x50 (0xD0)
+const TInt KErrIrObexRespNotImplemented = KErrIrObexRespBase - ERespNotImplemented; //-5581 returns 0x51 (0xD1)
+const TInt KErrIrObexRespBadGateway = KErrIrObexRespBase - ERespBadGateway; //-5582 returns 0x52 (0xD2)
+const TInt KErrIrObexRespServiceUnavail = KErrIrObexRespBase - ERespServiceUnavail; //-5583 returns 0x53 (0xD3)
+const TInt KErrIrObexRespGatewayTimeout = KErrIrObexRespBase - ERespGatewayTimeout; //-5584 returns 0x54 (0xD4)
+const TInt KErrIrObexRespHTTPVerNotSupp = KErrIrObexRespBase - ERespHTTPVerNotSupp; //-5585 returns 0x55 (0xD5)
+const TInt KErrIrObexRespDatabaseFull = KErrIrObexRespBase - ERespDatabaseFull; //-5596 returns 0x60 (0xE0)
+const TInt KErrIrObexRespDatabaseLocked = KErrIrObexRespBase - ERespDatabaseLocked; //-5597 returns 0x61 (0xE1)
+
+#endif // __OBEXCONSTANTS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexfinalpacketobserver.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,46 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXFINALPACKETOBSERVER_H
+#define OBEXFINALPACKETOBSERVER_H
+
+#include <e32std.h>
+
+/**
+This mixin class must be inherited by any class interested in final packet notifications.
+
+@publishedAll
+@released
+*/
+
+class MObexFinalPacketObserver
+ {
+public:
+
+ /** Indicates start of final packet.
+ @publishedAll
+ @released
+ */
+ virtual void MofpoFinalPacketStarted() {};
+
+ /** Indicates end of final packet.
+ @publishedAll
+ @released
+ */
+ virtual void MofpoFinalPacketFinished() {};
+ };
+
+#endif // OBEXFINALPACKETOBSERVER_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexheaders.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,239 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXHEADERS_H
+#define __OBEXHEADERS_H
+
+#include <obextypes.h>
+
+/**
+Encapsulates an Obex header.
+
+This class provides the ability to hold a header of any of the Obex
+supported types as a native Symbian OS type.
+
+A header may also have one or more attributes set. These are used by
+the object which owns the header collection so that it can keep track
+of which headers should be sent (!(ESuppressed || EDeleted)), which have
+been sent (ESent), and whether the header should be deleted (EDeleted).
+Deletion is a special case---any operation on the Object which causes
+a scan of the headers will trigger deletion of any marked headers.
+This is required as they are owned by the Object, but can be accessed
+seperately (including through the creator keeping a pointer to the
+header).
+
+@see CObexBaseObject
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexHeader) : public CBase
+ {
+public:
+ // Requires friendship with CObexBaseObject to support some aspects of the
+ // legacy API (specifically the HTTP accessor method).
+ friend class CObexBaseObject;
+
+ enum THeaderType
+ {
+ EUnicode = 0x00,
+ EByteSeq = 0x01,
+ EByte = 0x02,
+ EFourByte = 0x03
+ };
+
+ enum THeaderAttr
+ {
+ ESuppressed = 0x01,
+ ESent = 0x02,
+ EDeleted = 0x04,
+ };
+
+ IMPORT_C static CObexHeader* NewL();
+ virtual ~CObexHeader();
+ IMPORT_C CObexHeader* CopyL() const;
+
+ //Sets this object to use the same underlying header as the parameter.
+ IMPORT_C void Set(CObexHeader* aHeader);
+ //Resets the contents of this header, discarding the underlying data.
+ IMPORT_C void Reset();
+
+ //Resets and destroys all header attributes.
+ IMPORT_C void ResetContents();
+
+ IMPORT_C void SetAttributes(TUint16 aAttr);
+ IMPORT_C TUint16 Attributes() const;
+
+ IMPORT_C THeaderType Type() const;
+
+ IMPORT_C TUint8 HI() const;
+ IMPORT_C TUint8 AsByte() const;
+ IMPORT_C TUint32 AsFourByte() const;
+ IMPORT_C const TDesC8& AsByteSeq() const;
+ IMPORT_C const TDesC16& AsUnicode() const;
+
+ IMPORT_C void SetByte(const TUint8 aHI, const TUint8 aByte);
+ IMPORT_C void SetFourByte(const TUint8 aHI, const TUint32 aFourByte);
+ IMPORT_C void SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq);
+ IMPORT_C void SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode);
+
+ IMPORT_C TInt EncodedSize() const;
+
+private:
+ CObexHeader();
+ CObexHeader(CObexUnderlyingHeader* aHeader);
+ void ConstructL();
+
+private:
+ CObexUnderlyingHeader* iHeader;
+ };
+
+/**
+Used to allow the iterator to decide whether to present a header to
+the user, by passing in a possible header HI value. Headers present
+in the object will be presented to the Interested() function in the
+object in which they are held (if received from a remote device
+this will be the order in which they were received, otherwise this will
+be the order in which they were set).
+The function can implement any desired behaviour, including relying on
+the order in which the headers are presented.
+
+In case any state is held, the object also provides a Reset() function.
+Reset() provides a default empty implementation.
+
+Note: there is no destructor.
+
+@publishedAll
+@released
+*/
+class MObexHeaderCheck
+ {
+public:
+ /**
+ Called to discover is the user is interested in the contents of
+ this header.
+
+ @param aHI The identifier of the header, including type bits.
+ @return ETrue if the user is interested in the contents of this
+ header.
+ @publishedAll
+ @released
+ */
+ IMPORT_C virtual TBool Interested(TUint8 aHI) =0;
+
+ /**
+ Called in response to First() being called on the iterator object.
+ The default implementation does nothing---some implementations may
+ wish to reset state variables.
+
+ @publishedAll
+ @released
+ */
+ IMPORT_C virtual void Reset();
+
+ /**
+ Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
+ @param aInterface UID of the interface to return
+ @param aObject the container for another interface as specified by aInterface
+ @publishedAll
+ */
+ IMPORT_C virtual void MOHC_ExtensionInterfaceL(TUid aInterface, void*& aObject);
+ };
+
+/**
+A collection of headers. Includes code to filter based on the header HI
+value, iterate through the set of interesting headers, and extract headers
+with specific HI values.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexHeaderSet) : public CBase
+ {
+public:
+ IMPORT_C static CObexHeaderSet* NewL();
+ IMPORT_C CObexHeaderSet* CopyL();
+ IMPORT_C CObexHeaderSet* CopyL(MObexHeaderCheck& aHeaderCheck);
+ ~CObexHeaderSet();
+
+ IMPORT_C TInt AddHeader(CObexHeader* aHeader);
+ IMPORT_C void DeleteCurrentHeader();
+
+ IMPORT_C void SetMask(MObexHeaderCheck* aMask);
+ IMPORT_C void DeleteMasked();
+
+ IMPORT_C void First() const;
+ IMPORT_C TInt This(CObexHeader* aHeader) const;
+ IMPORT_C TInt Next() const;
+ IMPORT_C TInt Next(TInt aSkip) const;
+ IMPORT_C TInt Count() const;
+
+ IMPORT_C TInt Find(TUint8 aHI, CObexHeader& aHeader) const;
+
+private:
+ CObexHeaderSet();
+
+private:
+ RPointerArray<CObexHeader> iHeaders;
+ mutable MObexHeaderCheck* iMask;
+ mutable TInt iPos;
+ };
+
+/**
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexMatchHeader) : public MObexHeaderCheck
+ {
+public:
+ virtual EXPORT_C TBool Interested(TUint8 aHI);
+ IMPORT_C void SetHeader(TUint8 aHI);
+
+private:
+ TUint8 iHI;
+
+private:
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+/**
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexMatchHeaderType) : public MObexHeaderCheck
+{
+public:
+ virtual EXPORT_C TBool Interested(TUint8 aHI);
+ IMPORT_C void SetType(CObexHeader::THeaderType aType);
+
+private:
+ TInt iType;
+
+private:
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+#endif // __OBEXHEADERS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexobjects.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,341 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXOBJECTS_H
+#define __OBEXOBJECTS_H
+
+#include <obextypes.h>
+#include <obexbaseobject.h>
+#include <f32file.h>
+
+class MObexFileWriter;
+class TObexBufferingDetails;
+
+/**
+This class is a concrete derivation of the CObexBaseObject class. Use it to
+store and transfer OBEX objects with the body part stored in an EPOC file.
+Hence this class is particularly suited to OBEX "file" beaming applications
+(c.f. arbitrary object beaming), although there is in reality no
+restriction in what it is used to transfer. Access to the body is acheived
+through an additional attribute to the object; the data file. This is the
+file-system name of the file used to store the body of the object. Note
+that there is no explicit relation between this and the Name of the object,
+although it is expected that most applications would attempt to relate the
+two.
+
+When ever a valid data file is set (i.e. DataFile().Length > 0), this file
+is effectively open, hence stopping any other application from opening it
+with exclusive rights. Therefore, it is recommended that Reset () be called
+on the object as soon as it is no longer required, and definitely before
+(conceptually) passing ownership of the data file to any other object or
+user.
+
+CObexFileObject is also suited to situations where an object is expected to
+be received, but no information about the purpose of this object is known.
+This is due to CObexFileObject’s ability to create temporary files "on the
+fly" to store received data into, when a specific file is not provided by
+the application.
+
+This class is not designed for user derivation.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexFileObject) : public CObexBaseObject
+ {
+public:
+ static IMPORT_C CObexFileObject* NewL();
+ static IMPORT_C CObexFileObject* NewL(const TDesC &aDataFile);
+ virtual IMPORT_C ~CObexFileObject();
+ IMPORT_C void InitFromFileL(const TDesC& aFile);
+
+private:
+ void ConstructL(const TDesC &aDataFile);
+ void SetDataFileL(const TDesC& aDesc);
+ const TDesC& DataFile();
+ TBool RenameFile(const TDesC& aDesC);
+ void SetTempFilePath(const TDesC& aPath);
+ void QueryTempFilePath(TDes& aPath);
+ // From CObexBaseObject
+ virtual void GetData(TInt aPos, TDes8& aDes);
+ virtual void NewData(TInt aPos, TDes8& aDes);
+ virtual TInt DataSize();
+ virtual void ResetData();
+// Data
+private:
+ RFs iFs;
+ TParse iDataFile;
+ RFile iFile;
+ TBuf<KObexObjectDescriptionSize> iTempFilePath;
+ };
+
+
+
+/**
+Use this class to hold objects where the body part is stored in a CBufFlat
+object. Please note that although parameters are supplied as CBufBase objects,
+non-CBufFlat parameters are not supported and will have unpredictable results.
+At no point does the CObexBufObject create, or take ownership of any CBaseBuf
+object it uses - it is always the responsibility of the creator/owner of the
+CBaseBuf to free it when no longer required.
+
+As this class does not take ownership of the buffers it uses, it equally can
+not create its own buffers ad-hoc for storing new data into. Hence at no
+time is it valid for a CObexBufObject to exist with out it having a valid
+data buffer set. If such a situation arises, where it is required that
+received information should be discarded, consider using a CObexNullObject.
+
+It is also posible to supply a file instead of a memory buffer, or to supply
+both. This functionality is due to the MObexServerNotify class expecting to
+work only on CObexBufObjects, so CObexFileObjects cannot be returned from the
+upcalls.
+To use a file for body storage, call NewL() passing in a NULL pointer, then
+call SetDataBufL() manually afterwards. There are three overloads---to allow
+purely memory based objects, purely file based, or a hybrid. The hybrid object
+buffers into a memory buffer (which is not allowed to grow), then writes data
+to the file when the buffer is full. The buffering behaviour can therefore be
+tuned to the application by setting the size of the buffer prior to use.
+
+This class is not designed for user derivation.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexBufObject) : public CObexBaseObject
+ {
+public:
+ /**
+ Obex file buffering method.
+
+ @publishedAll
+ @released
+ */
+ enum TFileBuffering
+ {
+ /** Only the supplied buffer will be used to buffer file writes. */
+ ESingleBuffering,
+ /** The object will create a second buffer and perform double buffering. */
+ EDoubleBuffering
+ };
+
+public:
+ static IMPORT_C CObexBufObject* NewL(CBufBase* aDataBuf);
+ virtual IMPORT_C ~CObexBufObject();
+ IMPORT_C TInt WriteToFile(const TPtrC& aFileName);
+
+ IMPORT_C void SetDataBufL(TObexBufferingDetails& aDetails);
+ IMPORT_C void SetDataBufL(CBufBase* aDataBuf);
+ IMPORT_C void SetDataBufL(const TPtrC& aFilename);
+ IMPORT_C void SetDataBufL(const TPtrC& aFilename, CBufBase* aDataBuf);
+ IMPORT_C void SetDataBufL(const TPtrC& aFilename, CBufBase& aDataBuf, const TFileBuffering aBufferingStrategy);
+ IMPORT_C CBufBase* DataBuf();
+ HBufC* FileName();
+
+private:
+ CObexBufObject();
+ void ConstructL(CBufBase* aDataBuf);
+
+ void PrepareToSetBufferL();
+
+ void CopyFileL(const TDesC& aFilename);
+ TInt NewFileData(TInt aPos, TDes8& aDes);
+ void GetFileData(TInt aPos, TDes8& aDes);
+
+ // From CObexBaseObject
+ virtual void GetData(TInt aPos, TDes8& aDes);
+ virtual void NewData(TInt aPos, TDes8& aDes);
+ virtual TInt DataSize();
+ virtual void ResetData();
+
+ void CloseDataFile();
+ TInt OpenDataFile(const TDesC& aFilename);
+ void CloseFileServer();
+ TInt OpenFileServer();
+ TInt WriteBufferToFile(TBool aFinal);
+
+// Data
+private:
+ CBufBase* iBuf;
+ HBufC* iFilename;
+ RFs* iFileServ;
+ RFile* iFile;
+ TInt iBufOffset;
+ TInt iBuffered;
+ TInt iBufSegSize;
+
+// Added for double-buffering
+private:
+ // Owned
+ MObexFileWriter* iWriter;
+ CBufBase* iDoubleBuf;
+ };
+
+
+
+/**
+Wraps parameters which can affect the buffering method used by the
+CObexBufObject.
+This version provides a single memory buffer which holds the entire object.
+Subclasses will always use a memory buffer, but can override the way that
+Obex uses it.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexBufferingDetails)
+ {
+public:
+ /**
+ Versions (subclasses) of the buffering style object.
+ This enum should not be used outside the dll.
+ @internalComponent
+ */
+ enum TVersion
+ {
+ EBasicBuffer,
+ EPureFile,
+ EFilenameBackedBuffer,
+ ERFileBackedBuffer,
+ ELastVersion
+ };
+
+ IMPORT_C TObexBufferingDetails(CBufBase& aBuffer);
+
+ TVersion Version(); // Return the version of this object
+ CBufBase* Buffer();
+
+protected:
+ TObexBufferingDetails(TVersion aVersion, CBufBase* aBuffer);
+
+private:
+ TVersion iVersion;
+ CBufBase* iBuffer;
+
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+
+/**
+Provides alternate behaviour for a CObexBufObject, allowing use of a file
+to hold the object in its entirety. No memory buffer is used. This is a
+special case option provided to cater for the MObexServerNotify interface
+which requires the use of CObexBufObject objects. It is generally better to
+use a buffered variant.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexPureFileBuffer) : public TObexBufferingDetails
+ {
+public:
+ IMPORT_C TObexPureFileBuffer(const TPtrC& aFilename);
+ const TPtrC& Filename();
+
+private:
+ const TPtrC& iFilename;
+
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+/**
+Provides alternate behaviour for a CObexBufObject, allowing use of a file
+to hold the object in its entirety. Writes to this object are buffered through
+the supplied CBufBase derived object, which is never enlarged. Once
+it is full, the data is flushed to the file.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexFilenameBackedBuffer) : public TObexBufferingDetails
+ {
+public:
+ IMPORT_C TObexFilenameBackedBuffer(CBufBase& aBuffer, const TPtrC& aFilename, CObexBufObject::TFileBuffering aBufferingStrategy);
+ const TPtrC& Filename();
+ CObexBufObject::TFileBuffering Strategy();
+
+private:
+ const TPtrC& iFilename;
+ CObexBufObject::TFileBuffering iBufferingStrategy;
+
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+
+
+/**
+Provides alternate behaviour for a CObexBufObject, allowing use of a file
+to hold the object in its entirety. Writes to this object are buffered through
+the supplied CBufBase derived object, which is never enlarged. Once
+it is full, the data is flushed to the file.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(TObexRFileBackedBuffer) : public TObexBufferingDetails
+ {
+public:
+ IMPORT_C TObexRFileBackedBuffer(CBufBase& aBuffer, RFile aFile, CObexBufObject::TFileBuffering aBufferingStrategy);
+ RFile File();
+ CObexBufObject::TFileBuffering Strategy();
+
+private:
+ RFile iFile;
+ CObexBufObject::TFileBuffering iBufferingStrategy;
+
+ // This data padding has been added to help prevent future binary compatibility breaks
+ // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
+ TUint32 iPadding1;
+ TUint32 iPadding2;
+ };
+
+
+
+/**
+Concrete OBEX object with NULL data representation. Use when only the
+headers of an object are required, and the data (if any) can safely be
+discarded.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexNullObject) : public CObexBaseObject
+ {
+public:
+ IMPORT_C static CObexNullObject* NewL ();
+private:
+ // From CObexBaseObject
+ void ConstructL();
+ virtual void GetData (TInt aPos, TDes8& aDes);
+ virtual void NewData (TInt aPos, TDes8& aDes);
+ virtual TInt DataSize ();
+ virtual void ResetData ();
+ };
+
+#endif // __OBEXOBJECTS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexpanics.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,162 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEX_PANICS_H
+#define OBEX_PANICS_H
+
+/**
+@file
+@publishedAll
+@released
+
+This file contains details of all OBEX and OBEX Transport panics which may be raised
+as a result programming error by the users of OBEX (e.g. Client or Server Application
+or a proprietry transport controller).
+
+Internal panic codes should not be raised due to user errors but would reflect
+internal Obex programming errors - see inc/obexfaults.h
+*/
+
+
+/**
+Category for Obex panics
+@see TObexPanicCode
+*/
+_LIT(KObexPanicCategory, "Obex");
+
+/**
+@publishedAll
+@released
+
+All Obex panics which may be raised as a result of a client (i.e. external) programming error.
+Internal Obex panics are errors listed in TObexFaultCode
+@see TObexFaultCode
+*/
+enum TObexPanicCode
+ {
+ /** A NULL value was supplied for the data buffer. Note that this
+ pointer can refer to either a memory buffer or a pointer to a RFile object.
+ @see CObexBufObject
+ */
+ ENullPointer = 0,
+
+
+ /** The supplied buffer is of zero length.
+ @see CObexBufObject
+ */
+ EEmptyBuffer = 1,
+
+
+ /** The header is not of the requested type.
+ @see CObexHeader
+ */
+ EHeaderAsBadType = 2,
+
+
+ /** An unknown TFileBuffering value was supplied.
+ @see CObexBufObject
+ */
+ EInvalidBufferStrategy = 3,
+
+
+ /** The RFile object does not point to a valid (open) file.
+ @see CObexBufObject
+ */
+ ENullFileHandle = 4,
+
+
+ /** An unknown TObexBufferingDetails object was supplied to a buffer object.
+ @see CObexBufObject
+ */
+ EInvalidBufferDetails = 5,
+
+
+ /** A call has been made to CObexServer::RequestIndicationCallback when no
+ asynchronous request is outstanding.
+ @see MObexNotifyAsync
+ @see CObexServer
+ */
+ ENoNotificationToComplete = 6,
+
+
+ /** A call has been made to CObexServer::Start when an asynchronous request
+ is outstanding.
+ @see MObexNotifyAsync
+ @see CObexServer
+ */
+ EChangeInterfaceDuringWait = 7,
+
+
+
+ /** An invalid packet process event has been signalled.
+ */
+ EBadPacketProcessEvent = 8,
+
+
+ /** An event is available for signalling, but there is no observer set.
+ */
+ ENoPacketProcessObserverSet = 9,
+
+ /** In CObexServer, a call has been made to RequestCompleteIndicationCallback(TObexResponse)
+ or RequestIndicationCallback(TObexResponse) with invalid response code or
+ RequestCompleteIndicationCallback(TInt) with invalid Symbian error code
+ */
+ EInvalidResponseCodeFromServerApp = 10,
+
+ /** In CObexServer, RequestCompleteIndicationCallback has been called in response to Put/GetRequestIndication
+ or ReuqestIndicationCallback has been called in response to Put/GetComplete or SetPath Indication
+ */
+ EInvalidResponseCallback = 11,
+
+ /** The last server response code has been requested prior to a response from the server.
+ */
+ ENoResponseCodeToReturn = 12,
+
+ /** Adding End of Body header when there is data in the object.
+ */
+ EAddingInvalidEoBHeader = 13,
+
+ /** A user has requested to override the handling of a request
+ packet at an invalid time.
+ */
+ EOverrideRequestHandlingInBadState = 14,
+
+ /** A pointer must be null before constructing the object it points to.
+ */
+ ENotNullPointer = 15,
+ };
+
+
+
+/**
+The category for obex transport panics
+*/
+_LIT(KObexTransportPanicCat, "ObexTransPanics");
+
+/**
+Obex transport panics raised as a result of client programming error
+*/
+enum TObexTransportPanicCode
+ {
+ /**
+ The number of transport implementations for a given transport name is more than what is allowed.
+ Check that there is not more than the allowed number of plugin resource files containing the same default
+ data and inteface uid.
+ */
+ EInvalidNumberOfTransportImplementations = 0,
+ };
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexreadactivityobserver.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,48 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXREADACTIVITYOBSERVER_H
+#define OBEXREADACTIVITYOBSERVER_H
+
+#include <e32std.h>
+
+/**
+This mixin class must be inherited by any class interested in read activity notifications.
+
+@publishedPartner
+@released
+*/
+
+class MObexReadActivityObserver
+ {
+public:
+
+ /** Indicates read activity.
+ This is guaranteed to be called when the transport completes the first
+ transport read in an Obex operation (which may correspond to less than a
+ complete Obex packet), and may be called at additional times before the
+ operation is completed.
+ Note that the upcall behaviour is dependent on transport layer and
+ version -- even if experiments show more frequent upcalls, the only
+ behaviour which may be assumed is a single upcall per operation.
+
+ @publishedPartner
+ @released
+ */
+ virtual void MoraoReadActivity() {};
+ };
+
+#endif // OBEXREADACTIVITYOBSERVER_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obexserver.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,692 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXSERVER_H
+#define __OBEXSERVER_H
+
+#include <obextypes.h>
+#include <obexbase.h>
+
+class TObexTransportInfo;
+class CObexServerRequestPacketEngine;
+class CObexPacketSignaller;
+class MObexReadActivityObserver;
+
+/** OBEX server.
+
+CObexServer provides a framework for servicing OBEX requests from remote clients.
+It is designed to be able to act as either a "default" application (in IrDA
+terms, registering on the IrDA:OBEX IAS class), or as a application specific
+server (registering itself on a private IAS class).
+
+You implement service-specific behaviour by providing a MObexServerNotify
+interface implementation to the server object. The server calls the interface's
+functions to provide notification of server events, which specific implementations
+can process (or ignore) as appropriate.
+
+This class is not designed for user derivation.
+
+@publishedAll
+@released
+*/
+NONSHARABLE_CLASS(CObexServer) : public CObex
+ {
+ // CObexServer is friends with the core Server State Machine class so
+ // that it can access the CObex::ControlledTransportDown() method
+ friend class CObexServerStateMachine;
+
+ // CObexServer is friends with the TObexServerStateObexConnecting class so
+ // that it can access the CObex::SetConnectState(TConnectState aNewState) method
+ friend class TObexServerStateObexConnecting;
+
+ // CObexServer is friends with the Server Request Packet Engine so that
+ // it can NULL the iServerRequestPacketEngine pointer ready for another
+ // extension interface
+ friend class CObexServerRequestPacketEngine;
+
+public:
+ /**
+ @publishedAll
+ @released
+
+ The target header checking to apply to incoming connection requests. Defaults to
+ EIfPresent.
+ @see CObexServer::SetTargetChecking
+ */
+ enum TTargetChecking
+ {
+ ENoChecking, /** Allow all target headers to connect. */
+ EIfPresent, /** Only check target header in response to receiving one. Allows all clients
+ specifying an Inbox service to connect. */
+ EAlways, /** Strict checking. Only allow connections if target header matches or no header
+ received and none expected. */
+ };
+
+ IMPORT_C static CObexServer* NewL(TObexProtocolInfo& aObexProtocolInfoPtr);
+ IMPORT_C static CObexServer* NewL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy);
+ IMPORT_C static CObexServer* NewL(TObexTransportInfo& aObexTransportInfo);
+ ~CObexServer();
+ IMPORT_C TInt Start(MObexServerNotify* aOwner);
+ IMPORT_C TInt Start(MObexServerNotifyAsync* aOwner);
+ IMPORT_C void Stop();
+ IMPORT_C TBool IsStarted();
+ IMPORT_C TOperation CurrentOperation() const;
+ void SetCurrentOperation(const TOperation aOperation); // used internally by state machine
+ IMPORT_C void SetChallengeL(const TDesC& aPassword);
+ IMPORT_C void ResetChallenge();
+ IMPORT_C void UserPasswordL( const TDesC& aPassword);
+ IMPORT_C void SetTargetChecking(TTargetChecking aChecking);
+ IMPORT_C TInt SetPutFinalResponseHeaders(CObexHeaderSet* aHeaderSet);
+ IMPORT_C TInt RequestIndicationCallback(CObexBaseObject* aObject);
+ IMPORT_C TInt RequestIndicationCallbackWithError(TObexResponse aResponseCode);
+ IMPORT_C TInt RequestIndicationCallbackWithError(TInt aErrorCode);
+ IMPORT_C TInt RequestCompleteIndicationCallback(TObexResponse aResponseCode);
+ IMPORT_C TInt RequestCompleteIndicationCallback(TInt aErrorCode);
+
+ IMPORT_C TInt PacketHeaders(CObexHeaderSet*& aHeaderSet);
+ IMPORT_C TInt PacketHeaders(CObexHeaderSet*& aHeaderSet, MObexHeaderCheck& aHeaderCheck);
+ IMPORT_C void SetReadActivityObserver(MObexReadActivityObserver* aObserver);
+
+ IMPORT_C TAny* ExtensionInterfaceL(TUid aUid);
+ IMPORT_C const TObexTransportInfo* TransportInfo() const;
+
+public:
+ // Called from CObexNotifyExtendServer
+ void SignalPacketProcessEvent(TInt aEvent);
+
+ // Unexported functions used by the Server state machine
+ TBool CheckObjectForConnectionId(CObexBaseObject& aObject);
+ TBool CheckPacketForConnectionId(CObexPacket& aObject);
+
+private:
+ CObexServer();
+ void ConstructL(TObexTransportInfo& aObexTransportInfo);
+ TInt AcceptConnection();
+ // Implementation of CObex Events
+ virtual void OnPacketReceive(CObexPacket& aPacket);
+ virtual void OnError(TInt aError);
+ virtual void OnTransportUp();
+ virtual void OnTransportDown();
+
+public:
+ // These three functions need to be public so the Server state machine can use them
+ // However ParseConnectPacket cannot be moved as it is a virtual function (from CObex)
+ TInt PrepareConnectPacket(CObexPacket& aPacket);
+ TInt PrepareErroredConnectPacket(CObexPacket& aPacket);
+ void SignalReadActivity();
+ TInt ParseConnectPacket(CObexPacket& aPacket);
+
+private:
+ TInt AddConnectionIDHeader(CObexPacket& aPacket);
+ TInt PrepareFinalChallResponse(CObexPacket& aPacket, TConnectState& aNextState);
+ void CheckTarget(TConnectState& aNextState, TInt& aRetVal);
+ void ResetConnectionID();
+ void SetConnectionID(TUint32 aConnectionID);
+ TUint32 ConnectionID();
+ void CheckServerAppResponseCode(TObexOpcode aOpcode, TObexResponse aResponse);
+ TInt DoPacketHeaders(CObexHeaderSet*& aHeaderSet, MObexHeaderCheck* aHeaderCheck);
+
+private:
+ MObexServerNotifyAsync* iOwner;
+ TBool iEnabled;
+ TBool iSpecDone;
+ TBool iTargetReceived;
+ TTargetChecking iTargetChecking;
+ TUint32 iConnectionID;
+ TBool iConnectionIdSet;
+ CObexHeader* iHeader;
+ CObexServerStateMachine* iStateMachine;
+ CObexServerNotifySyncWrapper* iSyncWrapper;
+ CObexServerRequestPacketEngine* iServerRequestPacketEngine;
+ CObexPacketSignaller* iPacketProcessSignaller;
+ };
+
+
+/** OBEX synchronous server notification interface.
+
+Any service that provides OBEX server functionality must implement one of the two
+server observer classes -- this one or MObexServerNotifyAsync.
+
+The CObexServer object handles the protocol side of an OBEX server session,
+while this class provides the server policy for a particular session.
+
+PUT and GET requests are handled synchronously, with the implementer returning a
+CObexBufObject which will be processed immediately.
+
+@publishedAll
+@released
+@see MObexServerNotifyAsync
+@see CObexServer
+*/
+class MObexServerNotify
+ {
+public:
+ /**
+ Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
+ @param aInterface UID of the interface to return
+ @param aObject the container for another interface as specified by aInterface
+ */
+ IMPORT_C virtual void MOSN_ExtensionInterfaceL(TUid aInterface, void*& aObject);
+
+ /** Called if an OBEX protocol error occurs.
+
+ It is only called for fatal errors that cause the OBEX connection to terminate.
+ An error that does not terminate the connection, for example the server issuing
+ a semantically valid, but unrecognised command, will not be indicated.
+
+ @param aError Error code that describes the OBEX error. OBEX specific error
+ codes are listed from KErrIrObexClientNoDevicesFound.
+
+ @publishedAll
+ @released
+ */
+ virtual void ErrorIndication(TInt aError) =0;
+
+
+
+ /** Called when the underlying transport connection is made from a remote
+ client to the server.
+
+ Note that this does not, however, indicate an OBEX connection has been successfully
+ established.
+
+ You can define any low-level connection policy here. It is also a good place
+ to set up the local connection information (CObex::LocalInfo()), if any non-defaults
+ are required.
+
+ @publishedAll
+ @released
+ */
+ virtual void TransportUpIndication() =0;
+
+
+
+ /** Called when the transport connection is dropped (by either party).
+
+ It is called whether the OBEX connection was gracefully disconnected or not.
+ The function is the definitive place for disconnection processing.
+
+ @publishedAll
+ @released
+ */
+ virtual void TransportDownIndication() =0;
+
+
+
+ /** Called when an OBEX connection is made from a remote client.
+
+ Override this function to provide any extra OBEX connection processing.
+ Despite this method returning a value, implementers cannot use this to
+ refuse the connection attempt.
+
+ @param aRemoteInfo Connection information supplied by that remote machine
+ @param aInfo Further information about the requested connection (reserved)
+ @return Ignored
+
+ @publishedAll
+ @released
+ */
+ virtual TInt ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo) =0;
+
+
+
+ /** Called on a (graceful) OBEX disconnection by the client.
+
+ Override this to provide any extra processing OBEX disconnection processing.
+
+ Note that this indication will not be raised if the remote machine simply
+ drops the transport connection. However, ErrorIndication() will be called
+ if the disconnection is unexpected/ invalid (i.e. another operation was in
+ progress at the time). In all cases, TransportDownIndication() will be called.
+
+ @param aInfo Contains information about the disconnection (reserved)
+
+ @publishedAll
+ @released
+ */
+ virtual void ObexDisconnectIndication(const TDesC8& aInfo) =0;
+
+
+
+ /** Called on receipt of the first packet of a (valid) put request.
+
+ It is called before any parsing of the packet is performed, simply to establish
+ whether this server is interested in receiving objects at all.
+
+ Note if the returned object cannot be initialised for receiving, ERespInternalError
+ is returned to the client.
+
+ @return CObexBaseObject-derived object, which the object being put will be
+ parsed into. If this is NULL, ERespForbidden is returned to the client.
+
+ @publishedAll
+ @released
+ */
+ virtual CObexBufObject* PutRequestIndication() =0;
+
+
+
+ /** Called on receipt of every packet of an OBEX PUT operation.
+
+ It will always be preceded by a PutRequestIndication(). The object returned
+ by the request indication will be updated to reflect all the information received
+ concerning the object which the client is sending, from packets up to and
+ including the current one.
+
+ You can use this function to provide periodic user notification on the progress
+ of the transfer (noting that the Length attribute may take an arbitrary number
+ of packets to become non-zero, and the constraints on its accuracy). Due to
+ the nature of OBEX operations, where any header attribute can be sent at any
+ point in the transfer, this is also a good place to marshal the details of
+ a received object, and possibly prompt for action on the received object (e.g.
+ renaming on filename clashes).
+
+ Note that this function could be hit quite heavily, in proportion to the size
+ of the object transferred. Therefore more consideration should be given to
+ the speed of execution of this function than that of the other indications.
+
+ @return KErrNone instructs the server to allow the client to continue the put
+ operation. Any other value cancels the operation with an appropriate OBEX
+ server response code.
+
+ @publishedAll
+ @released
+ */
+ virtual TInt PutPacketIndication() =0;
+
+
+
+ /** Called after the final put packet has been successfully received and parsed.
+
+ Note that there will not necessarily be a call to this function corresponding
+ to each PutRequestIndication() as, if an error occurs while the put is being
+ carried out, ErrorIndication() will be called instead.
+
+ Before version 6.1, the return type was void.
+
+ @return KErrNoneinstructs the remote client that the put completed successfully.
+ Any other value cancels the operation with an appropriate OBEX server response
+ code.
+
+ @publishedAll
+ @released
+ */
+ virtual TInt PutCompleteIndication() =0;
+
+
+
+ /** Called when a full get request has been received from the client.
+
+ aRequestedObject holds all the details about the object the remote client
+ has requested. Use this function to analyse the client's request, and return
+ a pointer to the object to be returned to the client, or NULL to return no
+ object.
+
+ If NULL is returned, the server will send ERespForbidden to the client; if
+ an error occurs in returning the object, ERespInternalError is returned, otherwise
+ the returned object is sent back to the client.
+
+ @param aRequiredObject Details about the object the remote client has requested
+ @return Object to return to the client
+
+ @publishedAll
+ @released
+ */
+ virtual CObexBufObject* GetRequestIndication(CObexBaseObject *aRequiredObject) =0;
+
+
+
+ /** Called for every packet of get reply sent by the server back to the client.
+
+ The function is only called while an object is being sent to the client, not
+ while the client is providing its initial specification for the object it
+ requires.
+
+ You can use this function to provide user notification on the object being
+ sent, and its progress. As with PutPacketIndication(), you should consider
+ that this function might get called often, especially for large objects and
+ small OBEX packet sizes, so the speed of execution here is important.
+
+ @return KErrNone to continue sending the object, or any other error code to
+ cancel the operation
+
+ @publishedAll
+ @released
+ */
+ virtual TInt GetPacketIndication() =0;
+
+
+
+ /** Called when the final packet of the object has been returned to the client.
+
+ Note like PutCompleteIndication(), this function might not be called for each
+ GetRequestIndication(), if the operation is interrupted by an error.
+
+ Before version 6.1, the return type was void.
+
+ @return KErrNoneinstructs the remote client that the get completed successfully.
+ Any other value cancels the operation with an appropriate OBEX server response
+ code.
+
+ @publishedAll
+ @released
+ */
+ virtual TInt GetCompleteIndication() =0;
+
+
+
+ /** Called when an OBEX SETPATH command is received by the server.
+
+ @param aPathInfo SETPATH command parameters
+ @param aInfo Not currently used
+ @return System wide error code indicating the success of the setpath command
+
+ @publishedAll
+ @released
+ */
+ virtual TInt SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo) =0;
+
+
+
+ /** Called when an abort packet is received from the client.
+
+ An OBEX abort command simply cancels the current operation, and does not necessarily
+ have to cause the connection to be dropped. On return, a ERespSuccess packet
+ is sent to the client.
+
+ @publishedAll
+ @released
+ */
+ virtual void AbortIndication() =0;
+ };
+
+
+
+/** OBEX asynchronous server notification interface.
+
+Any service that provides OBEX server functionality must implement one of the two
+server observer classes -- this one or MObexServerNotify.
+
+The CObexServer object handles the protocol side of an OBEX server session,
+while this class provides the server policy for a particular session.
+
+PUT and GET requests are handled asynchronously, with the upcall from the server
+being followed at some stage in the future by a call to CObexServer::RequestIndicationComplete
+to trigger processing.
+
+@publishedAll
+@released
+@see MObexServerNotify
+@see CObexServer
+*/
+class MObexServerNotifyAsync
+ {
+public:
+
+ /**
+ Returns a null aObject if the extension is not implemented, or a pointer to another
+ interface if it is.
+ @param aInterface UID of the interface to return
+ @param aObject the container for another interface as specified by aInterface
+ */
+ IMPORT_C virtual void MOSNA_ExtensionInterfaceL(TUid aInterface, void*& aObject);
+
+
+
+ /** Called if an OBEX protocol error occurs.
+
+ It is only called for fatal errors that cause the OBEX connection to terminate.
+ An error that does not terminate the connection, for example the server issuing
+ a semantically valid, but unrecognised command, will not be indicated.
+
+ @param aError Error code that describes the OBEX error. OBEX specific error
+ codes are listed from KErrIrObexClientNoDevicesFound.
+
+ @publishedAll
+ @released
+ */
+ virtual void ErrorIndication(TInt aError) =0;
+
+
+
+ /** Called when the underlying transport connection is made from a remote
+ client to the server.
+
+ Note that this does not, however, indicate an OBEX connection has been successfully
+ established.
+
+ You can define any low-level connection policy here. It is also a good place
+ to set up the local connection information (CObex::LocalInfo()), if any non-defaults
+ are required.
+
+ @publishedAll
+ @released
+ */
+ virtual void TransportUpIndication() =0;
+
+
+
+ /** Called when the transport connection is dropped (by either party).
+
+ It is called whether the OBEX connection was gracefully disconnected or not.
+ The function is the definitive place for disconnection processing.
+
+ @publishedAll
+ @released
+ */
+ virtual void TransportDownIndication() =0;
+
+
+
+ /** Called when an OBEX connection is made from a remote client.
+
+ Override this function to provide any extra OBEX connection processing.
+
+ @param aRemoteInfo Connection information supplied by that remote machine
+ @param aInfo Further information about the requested connection (reserved)
+
+ @publishedAll
+ @released
+ */
+ virtual void ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo) =0;
+
+
+
+ /** Called on a (graceful) OBEX disconnection by the client.
+
+ Override this to provide any extra processing OBEX disconnection processing.
+
+ Note that this indication will not be raised if the remote machine simply
+ drops the transport connection. However, ErrorIndication() will be called
+ if the disconnection is unexpected/ invalid (i.e. another operation was in
+ progress at the time). In all cases, TransportDownIndication() will be called.
+
+ @param aInfo Contains information about the disconnection (reserved)
+
+ @publishedAll
+ @released
+ */
+ virtual void ObexDisconnectIndication(const TDesC8& aInfo) =0;
+
+
+
+ /** Called on receipt of the first packet of a (valid) put request.
+
+ It is called before any parsing of the packet is performed, simply to establish
+ whether this server is interested in receiving objects at all.
+
+ Following this notification, the server will wait for a call to
+ CObexServer::RequestIndicationCallback supplying a CObexBaseObject derived
+ object to receive into or a response code specifying the error.
+
+ @publishedAll
+ @released
+ */
+ virtual void PutRequestIndication() =0;
+
+
+
+ /** Called on receipt of every packet of an OBEX PUT operation.
+
+ It will always be preceded by a PutRequestIndication(). The object returned
+ by the request indication will be updated to reflect all the information received
+ concerning the object which the client is sending, from packets up to and
+ including the current one.
+
+ You can use this function to provide periodic user notification on the progress
+ of the transfer (noting that the Length attribute may take an arbitrary number
+ of packets to become non-zero, and the constraints on its accuracy). Due to
+ the nature of OBEX operations, where any header attribute can be sent at any
+ point in the transfer, this is also a good place to marshal the details of
+ a received object, and possibly prompt for action on the received object (e.g.
+ renaming on filename clashes).
+
+ Note that this function could be hit quite heavily, in proportion to the size
+ of the object transferred. Therefore more consideration should be given to
+ the speed of execution of this function than that of the other indications.
+
+ @return KErrNone instructs the server to allow the client to continue the put
+ operation. Any other value cancels the operation with an appropriate OBEX
+ server response code.
+
+ @publishedAll
+ @released
+ */
+ virtual TInt PutPacketIndication() =0;
+
+
+
+ /** Called after the final put packet has been successfully received and parsed.
+
+ Note that there will not necessarily be a call to this function corresponding
+ to each PutRequestIndication() as, if an error occurs while the put is being
+ carried out, ErrorIndication() will be called instead.
+
+ Following this notification, the server will wait for a call to
+ CObexServer::RequestCompleteIndicationCallback supplying a Obex response code.
+
+ @publishedAll
+ @released
+ */
+ virtual void PutCompleteIndication() =0;
+
+
+
+ /** Called when a full get request has been received from the client.
+
+ aRequestedObject holds all the details about the object the remote client
+ has requested. Use this function to analyse the client's request, and return
+ a pointer to the object to be returned to the client, or NULL to return no
+ object.
+
+ Following this notification, the server will wait for a call to
+ CObexServer::RequestIndicationCallback supplying a CObexBaseObject derived
+ object to send to the client or a response code specifying the error.
+
+ @param aRequiredObject Details about the object the remote client has requested
+
+ @publishedAll
+ @released
+ */
+ virtual void GetRequestIndication(CObexBaseObject* aRequiredObject) =0;
+
+
+
+ /** Called for every packet of get reply sent by the server back to the client.
+
+ The function is only called while an object is being sent to the client, not
+ while the client is providing its initial specification for the object it
+ requires.
+
+ You can use this function to provide user notification on the object being
+ sent, and its progress. As with PutPacketIndication(), you should consider
+ that this function might get called often, especially for large objects and
+ small OBEX packet sizes, so the speed of execution here is important.
+
+ @return KErrNone to continue sending the object, or any other error code to
+ cancel the operation
+
+ @publishedAll
+ @released
+ */
+ virtual TInt GetPacketIndication() =0;
+
+
+
+ /** Called when the final packet of the object has been returned to the client.
+
+ Note like PutCompleteIndication(), this function might not be called for each
+ GetRequestIndication(), if the operation is interrupted by an error.
+
+ Following this notification, the server will wait for a call to
+ CObexServer::RequestCompleteIndicationCallback supplying a Obex response code.
+
+ @publishedAll
+ @released
+ */
+ virtual void GetCompleteIndication() =0;
+
+
+
+ /** Called when an OBEX SETPATH command is received by the server.
+
+ Following this notification, the server will wait for a call to
+ CObexServer::RequestCompleteIndicationCallback supplying a Obex response code.
+
+ @param aPathInfo SETPATH command parameters
+ @param aInfo Not currently used
+
+ @publishedAll
+ @released
+ */
+ virtual void SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo) =0;
+
+
+
+ /** Called when an abort packet is received from the client.
+
+ An OBEX abort command simply cancels the current operation, and does not necessarily
+ have to cause the connection to be dropped. On return, a ERespSuccess packet
+ is sent to the client.
+
+ @publishedAll
+ @released
+ */
+ virtual void AbortIndication() =0;
+
+
+
+ /** Cancel an asynchronous callback request (ie. PutRequest/GetRequest/PutComplete/GetComplete/SetPath
+ notification).
+
+ Note that ignoring this call will lead to a panic when the indication callback function
+ is called.
+
+ @publishedAll
+ @released
+ */
+ virtual void CancelIndicationCallback() =0;
+ };
+
+
+#endif // __OBEXSERVER_H
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/public/obextypes.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,70 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+ @released
+*/
+
+#ifndef __OBEXTYPES_H
+#define __OBEXTYPES_H
+
+#include <e32std.h>
+#include <e32des8.h>
+#include <e32des16.h>
+#include <utf.h> // Required for source compatability
+#include <obexconstants.h>
+
+typedef TUint16 TObexHeaderMask;
+typedef TUint8 TObexOpcode;
+typedef TBuf8<16> TNonce;
+
+class TObexProtocolInfo;
+class TObexIrProtocolInfo;
+class TObexBluetoothProtocolInfo;
+class TObexUsbProtocolInfo;
+class TObexUsbProtocolInfoV2;
+class TObexProcotolPolicy;
+struct TObexConnectionInfo;
+class TObexConnectInfo;
+
+class CObexPacket;
+class CObexHeader;
+class CObexUnderlyingHeader;
+class MObexHeaderCheck;
+class CObexHeaderSet;
+class CObexBaseObject;
+class CObexFileObject;
+class CObexBufObject;
+class CObexNullObject;
+class MObexNotify;
+class MObexAuthChallengeHandler;
+class CObexTransport;
+class CObexConnector;
+class TObexInternalHeader;
+class CObexAuthenticator;
+class CObex;
+class TObexSetPathData;
+class CObexClient;
+class MObexServerNotify;
+class CObexServer;
+class CObexServerStateMachine;
+class MObexServerNotify;
+class MObexServerNotifyAsync;
+class CObexServerNotifySyncWrapper;
+
+
+#endif // __OBEXTYPES_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/OBEX.CPP Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,962 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#include <charconv.h>
+#include <utf.h>
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obextransportinfo.h>
+#include <obexirtransportinfo.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include <obex/internal/obexpacket.h>
+#include "logger.h"
+#include "obexsetpathdata.h"
+#include "OBEXUTIL.H"
+#include "authentication.h"
+#include <ecom/ecom.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+Constructor - set initial values and copy in protocol policy information
+@internalComponent
+*/
+CObex::CObex()
+ {
+#ifdef _DEBUG
+ CObexLog::Connect();
+#endif
+ FLOG(_L("Creating CObex"));
+ SetConnectState(EConnIdle);
+ }
+
+void CObex::ConstructL(TObexTransportInfo& aObexTransportInfo)
+ {
+ iTransportController = CObexTransportControllerBase::NewL(aObexTransportInfo);
+ iAuthEngine = CObexAuthenticator::NewL();
+ iSuppressedObexAuthElements = EObexNoSuppressedAuthElements;
+ }
+
+/**
+Destructor.
+*/
+CObex::~CObex()
+ {
+
+ delete iTransportController;
+ delete iAuthEngine;
+ delete iChallPassword;
+ delete iRespPassword;
+ delete iRemoteUID;
+ delete iRemoteRealm;
+ delete iRxChallenge;
+
+ // This must be done AFTER destroying the transport controller.
+ REComSession::FinalClose();
+
+ // iNotifyHandler is deleted in the derived classes where it is instantiated
+
+#ifdef _DEBUG
+ CObexLog::Close();
+#endif
+ }
+
+/**
+Get the socket address of the remote device.
+
+This is the address of the device OBEX is connected to over an IrDA or Bluetooth
+socket.
+
+@param aAddr Socket address.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObex::RemoteAddr(TSockAddr& aAddr)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // iTransportController must be valid for all the CObex life cycle
+ __ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+
+ iTransportController->RemoteAddr(aAddr);
+ }
+
+/**
+Sets the local Who field.
+
+This is used to identify the local end of the OBEX session when the OBEX connection
+is made. If it is required, set it before establishing the connection.
+
+@param aInfo Who field
+@return KErrNone or KErrArgument if aInfo is empty
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObex::SetLocalWho(const TDesC8& aInfo)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(aInfo.Length())
+ { iLocalInfo.iWho.Copy(aInfo); return KErrNone;}
+ else
+ return KErrArgument;
+ }
+
+/**
+Indicates if the Server / Client is currently authenticating the OBEX
+connection.
+
+@return ETrue if the Server / Client is currently authenticating the OBEX connection otherwise EFalse.
+
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObex::IsAuthenticating() const
+ {
+ return (ConnectState() >= EConnChallRxed && ConnectState() <= EWaitForUserInput);
+ }
+
+
+/**
+@param aPassword Password to use in challenge response
+@internalComponent
+*/
+void CObex::PrepareChallResponseL(const TDesC& aPassword)
+ {
+
+ FLOG(_L("CObex::PrepareChallResponse\r\n"));
+ iOutgoingChallResp.Zero();
+ TRequestDigest response;
+ delete iRespPassword;
+ iRespPassword = NULL;
+ iRespPassword = HBufC8::NewL(aPassword.Length());
+ TPtr8 ptr = iRespPassword->Des();
+ CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr, aPassword);
+
+ iAuthEngine->GenerateResponseL(ptr, iIncomingNonce, response);
+ FLOG(_L("PrepareChallResponse: Digest response generated"));
+
+ FLOG(_L("PrepareChallResponse: Adding response hash"));
+ iOutgoingChallResp.Append(KObexRespTag); //0x00
+ iOutgoingChallResp.Append(KObexRespSize); //16
+ iOutgoingChallResp.Append(response);
+
+ //only reply with UserID if requested
+ if (iUserIDRequested )
+ {
+ FLOG(_L("PrepareChallResponse: User ID required, adding zero length field"));
+ iOutgoingChallResp.Append(KObexRespUserIDTag); //0x01
+ //Fixme, add in the size of the user ID
+ iOutgoingChallResp.Append(0); //assume no UserID size of 0
+ //any user ID would have to be inserted here
+ //iOutgoingChallResp.Append(userID); //Fixme what is the user ID?
+ }
+
+ FLOG(_L("PrepareChallResponse: Adding nonce of challenge we're replying to"));
+ iOutgoingChallResp.Append(KObexRespNonceTag);
+ iOutgoingChallResp.Append(KObexNonceSize);
+ iOutgoingChallResp.Append(iIncomingNonce);
+
+ FLOG(_L(" PrepareChallResponse - complete response generated"));
+ }
+
+/**
+@internalComponent
+*/
+TInt CObex::GenerateChallenge(CObexPacket& aPacket)
+ {
+ TInt retValue = KErrNone;
+
+ FLOG(_L("CObex::GenerateChallenge\r\n"));
+ iOutgoingNonce.Zero();
+ iAuthEngine->GenerateNonce(iOutgoingNonce);
+ //now pack all the data together for the overall challenge
+ TBuf8<KObexChallHeaderSize> outGoingHeader; //this size assumes no Realm data
+ outGoingHeader.Zero();
+ outGoingHeader.Append(KObexChallNonceTag);
+ outGoingHeader.Append(KObexNonceSize);
+ outGoingHeader.Append(iOutgoingNonce);
+
+ // Add authentication header only if the client has not disallowed it
+ if (!(iSuppressedObexAuthElements & EObexSuppressChallengeOptionsAuthElement))
+ {
+ outGoingHeader.Append(KObexChallOptionsTag);
+ outGoingHeader.Append(1); //size is always 1
+ outGoingHeader.Append(0); //all options off
+ }
+
+ // Add realm header only if the client has not disallowed it
+ if (!(iSuppressedObexAuthElements & EObexSuppressRealmAuthElement))
+ {
+ outGoingHeader.Append(KObexChallRealmTag);
+ outGoingHeader.Append(0); //no realm so size = 0
+ }
+
+ TObexInternalHeader hdr;
+ hdr.Set(TObexInternalHeader::EAuthChallenge, (const_cast<TUint8*> (outGoingHeader.Ptr())), outGoingHeader.Size());
+ if(!aPacket.InsertData(hdr))
+ retValue = KErrOverflow;
+
+ return (retValue);
+ }
+
+/**
+@internalComponent
+*/
+void CObex::ProcessChallResponseL(const TObexInternalHeader& hdr)
+ {
+ FLOG(_L("CObex::ProcessChallResponse"));
+ TBool retValue = ETrue;
+ TInt responseSize = hdr.HVSize();
+ TInt elementsLeft = responseSize; //keep track of how many elements still to be removed
+
+ if ( responseSize > KChallResponseSize )
+ {
+ retValue = EFalse;
+ FLOG(_L("ProcessChallResponse - Response header too big FAILED"));
+ }
+ else if (responseSize < KMinChallResponseSize)
+ {
+ retValue = EFalse;
+ FLOG(_L("ProcessChallResponse - Response header too small FAILED"));
+ }
+
+ //get the response
+ iIncomingChallResp.Zero();
+ iIncomingChallResp.Copy(hdr.HVByteSeq(), responseSize);
+
+ //there is no reason to assume that the data is going to arrive
+ //in any particular order
+ TInt extractionPosn = 0;
+
+ //ensure space enough for the tag and size
+ while ((extractionPosn < (responseSize-1) ) && retValue)
+ {
+ switch (iIncomingChallResp[extractionPosn++])
+ {
+ case KObexRespTag:
+ {
+ elementsLeft--; //moved passed the tag
+ if ((iIncomingChallResp[extractionPosn++] == KObexRespSize)&&
+ (elementsLeft > KObexRespSize)) //must be greater to allow for size field
+ {
+ elementsLeft--; //moved passed the size
+ FLOG(_L("ProcessChallResponse - iIncoming Request Response extracted"));
+ iIncomingRequestDigest.Zero();
+ iIncomingRequestDigest.Append((TUint8*)iIncomingChallResp.Ptr() + extractionPosn, KObexRespSize);
+ extractionPosn += KObexRespSize;
+ elementsLeft -= KObexRespSize;
+ }
+ else
+ {
+ FLOG(_L("ProcessChallResponse - iIncoming Request Response extraction FAILED"));
+ retValue = EFalse;
+ }
+ }
+ break;
+ case KObexRespUserIDTag:
+ {
+ elementsLeft--; //moved passed the tag
+ TInt userIDSize = iIncomingChallResp[extractionPosn++];
+ if ( userIDSize > 0)
+ {
+ elementsLeft--; //moved passed the User ID size
+ if (( userIDSize > 0 )&&(userIDSize <= elementsLeft ))
+ {
+ elementsLeft -= userIDSize;
+ FLOG(_L("ProcessChallResponse - iIncoming ASCII UserID Extracted"));
+ delete iRemoteUID;
+ iRemoteUID = NULL;
+ iRemoteUID = HBufC::NewL(userIDSize);
+ TPtrC8 ptr((TUint8*)iIncomingChallResp.Ptr() + extractionPosn, userIDSize);
+ TPtr ptrUID((TUint16*)iRemoteUID->Ptr(), userIDSize);
+ CnvUtfConverter::ConvertToUnicodeFromUtf8(ptrUID, ptr);
+ extractionPosn += userIDSize;
+ }
+ }
+ else
+ {
+ retValue = EFalse;
+ FLOG(_L("ProcessChallResponse - iIncoming UserID Extraction FAILED"));
+ }
+ }
+ break;
+ //don't bother extracting the Nonce as we do not support multiple Nonce replies
+ //the assumption is the reply received is for the Nonce we sent out
+ case KObexRespNonceTag:
+ {
+ FLOG(_L("ProcessChallResponse: extracting incoming nonce"));
+ elementsLeft--; //moved passed the tag
+ TInt nonceSize = iIncomingChallResp[extractionPosn++];
+ if ( nonceSize > 0 )
+ {
+ elementsLeft--; //moved passed size
+ if ( nonceSize <= elementsLeft )
+ {
+ FTRACE(
+ TPtrC8 incomingNonce(iIncomingChallResp.Ptr() + extractionPosn, nonceSize);
+ if (incomingNonce != iOutgoingNonce)
+ {
+ FLOG(_L("ProcessChallResponse: incoming nonce does not match our challenge. Continuing anyway."));
+ }
+ );
+
+ elementsLeft -= nonceSize;
+ extractionPosn += nonceSize;
+ }
+ else
+ {
+ FLOG(_L("ProcessChallResponse - iIncoming Request Response extraction, bad nonce size FAILED"));
+ retValue = EFalse;
+ }
+ }
+ }
+ break;
+ default:
+ {
+ FLOG(_L("ProcessChallResponse - iIncoming Request Response extraction,unknown tag type FAILED"));
+ retValue = EFalse;
+ }
+ break;
+
+ }
+ TRAPD(err, iAuthEngine->ChallengeResponseL(*iChallPassword, iOutgoingNonce, iIncomingRequestDigest));
+ if ( err != KErrNone)
+ {
+ FLOG(_L("ProcessChallResponse - Responsed Denied"));
+ User::Leave(err);
+ }
+ }
+ if (!retValue )
+ User::Leave(KErrGeneral);
+ }
+
+/**
+@internalComponent
+*/
+void CObex::ProcessChallengeL(const TObexInternalHeader& hdr)
+ {
+ FLOG(_L("CObex::ProcessChallenge\n\r"));
+
+ //extract all the necessary data
+ TInt challengeSize = hdr.HVSize();
+ TInt extractionPosn = 0;
+ TInt elementsLeft = challengeSize;
+ TBool nonceExtracted = EFalse;
+
+ delete iRxChallenge;
+ iRxChallenge = NULL;
+ iRxChallenge = HBufC8::NewL(challengeSize);
+ iRxChallenge->Des().Copy(hdr.HVByteSeq(), challengeSize);
+ delete iRemoteRealm;
+ iRemoteRealm = NULL;
+
+
+
+ //can't make any assumptions about the order
+ //in which anything may arrive, so allow any old order
+ TBool exit = EFalse;
+ if ( challengeSize < (KObexNonceSize + 2))
+ {
+ FLOG(_L("CObex::ProcessChallenge incoming Challenge too small\n\r"));
+ User::Leave(KErrGeneral);
+ }
+
+ //must be space for Tag and size
+ while ((elementsLeft > 2) && (!exit))
+ {
+ switch (iRxChallenge->Des()[extractionPosn++])
+ {
+ case KObexChallNonceTag: //check the Nonce tag has arrived
+ {
+ elementsLeft--; //passed the tag posn
+ if (( iRxChallenge->Des()[extractionPosn++] == KObexNonceSize )
+ && (elementsLeft > KObexNonceSize))
+ {
+ FLOG(_L("CObex::ProcessChallenge incoming Nonce Extracted\n\r"));
+ iIncomingNonce.Zero();
+ //extract the Nonce data
+ TPtr8 ptr((TUint8*)iRxChallenge->Ptr() + extractionPosn
+ ,KObexNonceSize, KObexNonceSize);
+ iIncomingNonce.Append(ptr);
+ elementsLeft -= (KObexNonceSize + 1);
+ nonceExtracted = ETrue;
+ extractionPosn += KObexNonceSize;
+ }
+ else
+ {
+ FLOG(_L("CObex::ProcessChallenge Incorrect Nonce size\n\r"));
+ exit = ETrue;
+ }
+ }
+ break;
+ case KObexChallOptionsTag:
+ {
+ elementsLeft--; //passed the tag posn
+ //check the options flag
+ iUserIDRequested = EFalse;
+ if (( iRxChallenge->Des()[extractionPosn++] == KObexChallOptionSize )
+ && (elementsLeft > KObexChallOptionSize))
+ {
+ //check if the user ID is required in the reply
+ if ( iRxChallenge->Des()[extractionPosn++] & KObexRequireUID )
+ {
+ //the userID has been requested so it MUST be sent back in the chall response
+ iUserIDRequested = ETrue;
+ FLOG(_L("CObex::ProcessChallenge User ID Requested\n\r"));
+ }
+ elementsLeft -= (KObexChallOptionSize + 1);
+
+ }
+ else
+ {
+ FLOG(_L("CObex::ProcessChallenge Incorrect Options size\n\r"));
+ exit = ETrue;
+ }
+ }
+ break;
+ case KObexChallRealmTag:
+ {
+ elementsLeft--; //passed the tag posn
+ TInt size = iRxChallenge->Des()[ extractionPosn++ ];
+ elementsLeft--;
+ if ( (size > 0 ) && (size <= elementsLeft ) )
+ {
+ elementsLeft -= size;
+ size--; //remove the first byte
+ //check which format the data is in
+ TUint convertType=0;
+ switch(iRxChallenge->Des()[extractionPosn++])
+ {
+ case 0:
+ convertType=KCharacterSetIdentifierAscii;
+ break;
+ case 1:
+ convertType=KCharacterSetIdentifierIso88591;
+ break;
+ case 2:
+ convertType=KCharacterSetIdentifierIso88592;
+ break;
+ case 3:
+ convertType=KCharacterSetIdentifierIso88593;
+ break;
+ case 4:
+ convertType=KCharacterSetIdentifierIso88594;
+ break;
+ case 5:
+ convertType=KCharacterSetIdentifierIso88595;
+ break;
+ case 6:
+ convertType=KCharacterSetIdentifierIso88596;
+ break;
+ case 7:
+ convertType=KCharacterSetIdentifierIso88597;
+ break;
+ case 8:
+ convertType=KCharacterSetIdentifierIso88598;
+ break;
+ case 9:
+ convertType=KCharacterSetIdentifierIso88599;
+ break;
+ case 0xFF:
+ // Unicode, no conversion needed
+ break;
+ default:
+ User::Leave(KErrGeneral);
+ }
+
+ if(convertType)
+ {
+ RFs fs;
+ LEAVEIFERRORL(fs.Connect());
+ CleanupClosePushL(fs);
+ CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC();
+ if (converter->PrepareToConvertToOrFromL(convertType, fs) != CCnvCharacterSetConverter::EAvailable)
+ User::Leave(KErrGeneral);
+
+ iRemoteRealm = HBufC::NewL(size);
+ TPtr16 dest = iRemoteRealm->Des();
+ TInt state=CCnvCharacterSetConverter::KStateDefault;
+ TInt err = converter->ConvertToUnicode(dest, iRxChallenge->Mid(extractionPosn, size), state);
+ if (err < 0)
+ User::Leave(err);
+ CleanupStack::PopAndDestroy(2); // fs, converter
+ }
+ else //can only be unicode
+ { //if unicode
+ FLOG(_L("CObex::ProcessChallenge incoming UNICODE Realm extracted\n\r"));
+ size = size/2; //if it's UNICODE then should be an even number
+ iRemoteRealm = HBufC::NewMaxL(size);
+ TPtr16 dest = iRemoteRealm->Des();
+ for ( TInt x = 0; x < size; x++ )
+ dest[x] = LittleEndian::Get16((TUint8*)iRxChallenge->Ptr() + extractionPosn + (2*x));
+ extractionPosn += size * 2;
+ }
+
+ }
+ else
+ {
+ FLOG(_L("CObex::ProcessChallenge Incorrect Realm size\n\r"));
+ exit = ETrue;
+ }
+ }
+ break;
+ default:
+ {
+ FLOG(_L("CObex::ProcessChallenge Unknown Tag type\n\r"));
+ exit = ETrue;
+ }
+ break;
+ }
+ }
+ if ( !nonceExtracted) //the nonce is mandatory so must exist
+ {
+ FLOG(_L("CObex::ProcessChallenge Nonce was not extracted\n\r"));
+ exit = ETrue;
+ }
+ if ( exit )
+ User::Leave(KErrGeneral);
+ }
+
+
+/**
+Sets the authentication challenge handler.
+
+The caller must supply a MObexAuthChallengeHandler implementation to handle
+calls from the Server/Client for a request for a password.
+
+@param aCallBack Authentication challenge handler
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObex::SetCallBack(MObexAuthChallengeHandler& aCallBack)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iCallBack = &aCallBack;
+ }
+
+/**
+@internalTechnology
+
+This function is retained for backwards compatibility and should not be called.
+
+Calling this function has undefined behaviour.
+*/
+void CObex::Process(CObexPacket& aPacket)
+ {
+ NotifyProcess(aPacket);
+ }
+
+/**
+@internalTechnology
+
+This function is retained for backwards compatibility and should not be called.
+
+Calling this function has undefined behaviour.
+*/
+void CObex::Error(TInt aError)
+ {
+ NotifyError(aError);
+ }
+
+/**
+@internalTechnology
+
+This function is retained for backwards compatibility and should not be called.
+
+Calling this function has undefined behaviour.
+*/
+void CObex::TransportUp()
+ {
+ NotifyTransportUp();
+ }
+
+/**
+@internalTechnology
+
+This function is retained for backwards compatibility and should not be called.
+Use ControlledTransportDown() or ForcedTransportDown() to disconnect the transport layer.
+Calling this function will result in an ETransportDownCalled panic.
+
+@panic ObexFault ETransportDownCalled
+@see ControlledTransportDown()
+@see ForcedTransportDown()
+*/
+void CObex::TransportDown(TBool)
+ {
+ IrOBEXUtil::Fault(ETransportDownCalled);
+ }
+
+
+void CObex::NotifyProcess(CObexPacket& aPacket)
+ {
+ LOG2(_L8("Packet Received, opcode: 0x%2X, Length: %d"),
+ aPacket.Opcode(), aPacket.PacketSize());
+ FTRACE(aPacket.Dump());
+ OnPacketReceive(aPacket);
+ // The queuing of the next read packet varies between Server and Client
+ // Client is done at the end of CObexClient::OnPacketReceive
+ // Server is done once the write packet completes in CObexServer::SignalPacketProcessEvent
+ // This is because the Server may be mid-way through an asynchronous operation after OnPacketReceive
+ // so we have to keep the current read packet
+ if ((GetConnectState() == EWaitForUserInput )&&(iCallBack))
+ {
+ TRAPD(err, iCallBack->GetUserPasswordL(iRemoteRealm ? static_cast<TDesC&>(*iRemoteRealm) : KNullDesC()));
+ if ( err )
+ {
+ Error(err);
+ }
+ }
+ }
+
+void CObex::NotifyError(TInt aError)
+ {
+ LOG1(_L8("Error Called: %d"), aError);
+
+ // This call has been moved to before ForcedTransportDown(), because it
+ // needs to check whether the current operation is "disconnect" or
+ // not, and ForcedTransportDown() sets it to "idle".
+ OnError(aError);
+
+ if(iConnectState >= EConnTransport)
+ {
+ ForcedTransportDown();
+ }
+ }
+
+void CObex::NotifyTransportUp()
+ {
+ FLOG(_L("CObex::NotifyTransportUp\n\r"));
+ SetConnectState(EConnTransport);
+ OnTransportUp();
+ }
+
+void CObex::NotifyTransportDown(TBool)
+ {
+ IrOBEXUtil::Fault(ETransportDownCalled);
+ }
+
+/**
+This function forces the transport to be taken down
+regardless of whether or not the underlying transport can recover without
+restarting obex applications
+However if the transport controller fails to bring the transport down, then only
+the obex connection is cancelled.
+This is called in error conditions
+
+@see ControlledTransportDown()
+@internalComponent
+*/
+void CObex::ForcedTransportDown()
+ {
+ // iTransportController must be valid for all the CObex life cycle
+ __ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+
+ if (iTransportController->BringTransportDown())
+ {
+ SetConnectState(EConnIdle);
+ OnTransportDown();
+ }
+ else
+ {
+ //the transport failed to be taken down
+ CancelObexConnection();
+ }
+ RemoteInfoCleanup();
+ }
+
+/**
+This function will tear down the transport if the transport layer supports
+transport reconnection on obex reconnection
+This is called in conditions other than error conditions
+
+@see ForcedTransportDown()
+@internalComponent
+*/
+void CObex::ControlledTransportDown()
+ {
+ // iTransportController must be valid for all the CObex life cycle
+ __ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+
+ TBool canBringTransportDown = iTransportController->IsTransportRestartable();
+ if (canBringTransportDown)
+ {
+ ForcedTransportDown();
+ }
+ else
+ {
+ CancelObexConnection();
+ RemoteInfoCleanup();
+ }
+
+ }
+
+/**
+General cleanup of iRemoteInfo
+@internalComponent
+*/
+void CObex::RemoteInfoCleanup()
+ {
+ // Some general cleanup here.
+ iRemoteInfo.iTargetHeader.SetLength(0);
+ iRemoteInfo.iWho.SetLength(0);
+ }
+
+/**
+Put into transport connected state but cancel any outstanding transfers and operations
+@internalComponent
+*/
+void CObex::CancelObexConnection()
+ {
+ // iTransportController must be valid for all the CObex life cycle
+ __ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+
+ iTransportController->CancelTransfers();
+ SetConnectState(EConnTransport);
+ iCurrentOperation = EOpIdle;
+ }
+
+/**
+Change the state of the authentication state machine
+@param aNewState New state
+@internalComponent
+*/
+void CObex::SetConnectState(TConnectState aNewState)
+ {
+ switch(iConnectState = aNewState)
+ {
+ case EConnIdle:
+ FLOG(_L("### Connection State EConnIdle\r\n"));
+ break;
+ case EConnTransport:
+ FLOG(_L("###### Connection State EConnTransport\r\n"));
+ break;
+ case ESimpleConnRequest:
+ FLOG(_L("######### Connection State ESimpleConnRequest\r\n"));
+ break;
+ case EConnObex:
+ FLOG(_L("######### Connection State EConnObex\r\n"));
+ break;
+ case EConnChallRxed:
+ FLOG(_L("######### Connection State EConnChallRxed\r\n"));
+ break;
+ case ESimpleConnChallIssued:
+ FLOG(_L("######### Connection State ESimpleConnChallIssued\r\n"));
+ break;
+ case EChallConnRequested:
+ FLOG(_L("######### Connection State EChallConnRequested\r\n"));
+ break;
+ case EChallConnChallIssued:
+ FLOG(_L("######### Connection State EChallConnChallIssued\r\n"));
+ break;
+ case EWaitForFinalResponse:
+ FLOG(_L("######### Connection State EWaitForFinalResponse\r\n"));
+ break;
+ case EFinalChallRxed:
+ FLOG(_L("######### Connection State EConnChallReIssued\r\n"));
+ break;
+ case EDropLink:
+ FLOG(_L("######### Connection State EDropLink\r\n"));
+ break;
+ default:
+ break;
+ }
+ }
+
+// CObex::TSetPathInfo
+/**
+Constructor.
+
+This is the path information used in the SETPATH command.
+The variable iFlags is set to zero by default. The variable iConstants is always set to zero as this is a reserved
+varaible. The path name is NOT present by default.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObex::TSetPathInfo::TSetPathInfo()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iFlags = 0;
+ iConstants = 0;
+ iNamePresent = EFalse;
+ }
+
+/**
+@internalComponent
+*/
+CObex::TSetPathInfo::TSetPathInfo(const TObexSetPathData& aData)
+ : iFlags(aData.iFlags), iConstants(aData.iConstants), iNamePresent(EFalse)
+ {
+ }
+
+/**
+Returns true if the flags are set so that the receiver will backup a level before applying the path name
+
+@return ETrue if the flags are set so that the receiver will backup a level before applying the path name othewise EFalse.
+
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObex::TSetPathInfo::Parent() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return(iFlags & KObexSetPathParent);
+ }
+
+// CObex
+/**
+Returns ETrue if this CObex is connected at an OBEX level, merely having
+a transport connected does not satisfy this condition. I.e. the two devices
+must have completed the OBEX connection request/response . All other states
+return EFalse. This will be unreliable if either the server blindly
+returns the client’s who header (always reporting ETrue), or if neither
+supply "who" headers (always reporting EFalse).
+
+@return ETrue if this CObex is connected at an OBEX level. EFalse otherwise.
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObex::IsConnected() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return(GetConnectState() == EConnObex);
+ }
+
+/**
+@return ETrue if the "who" header specified in the server’s connect response
+ matched that of the client’s connect request, and both had a length greater
+ than 0 (i.e. both specified a "who" field). Undefined if IsConnected() == EFalse.
+
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObex::IsStrictPeer() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return((iLocalInfo.iWho.Length()>0) && (iLocalInfo.iWho==iRemoteInfo.iWho));
+ }
+
+/**
+Use this member to gain access to (and alter, if necessary) the
+CObex::TConnectInfo structure which will be sent to the OBEX peer as part
+of the connection process. Only alter the contents of this having read and
+understood the purpose of the fields, as defined in the OBEX spec. Altering
+this structure after a connection has been made will have no effect on the
+current session, but will be used for future connection attempts.
+
+@return The connect info which will be sent to the OBEX peer.
+@publishedAll
+@released
+*/
+EXPORT_C const TObexConnectInfo& CObex::LocalInfo() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return(iLocalInfo);
+ }
+
+/**
+Use this member to read the details of the remote machine’s connection
+information, as specified by it in during OBEX connection. This data can
+not be altered, as this serves no purpose.
+The content of this structure is undefined when @see IsConnected () ==
+EFalse.
+
+@return The connect info from the remote machine.
+@publishedAll
+@released
+*/
+EXPORT_C const TObexConnectInfo& CObex::RemoteInfo() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return(iRemoteInfo);
+ }
+
+/**
+This function is in the protected scope of CObex and so is not externally usable
+@publishedAll
+@released
+*/
+EXPORT_C CObex::TConnectState CObex::ConnectState() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // This function is exported but protected, making it not much use
+ // Making it public, and exposing more information about the authentication
+ // state machine is undesirable, but a public function is required for other
+ // classes in the DLL. Thus another public, unexported function has been defined
+ // on to which this function chains.
+ return GetConnectState();
+ };
+
+/**
+Get the current state of the authentication state machine
+@internalComponent
+*/
+CObex::TConnectState CObex::GetConnectState() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iConnectState;
+ };
+
+/**
+Must be called by an application that wishes to suppress the authentication or(not excusive) the realm of the authentication challenge
+@param aSuppressedObexAuthElements enum TObexSuppressedAuthElements to indicate which header elements to surpress (if any)
+@panic KErrArgument if invalid value is passed in for enum
+@publishedAll
+@released
+*/
+EXPORT_C void CObex::SuppressAuthenticationHeaderElements(TObexSuppressedAuthElements aSuppressedObexAuthElements)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // If the value passed in is not a valid bitmask then panic
+ _LIT(panicText, "Invalid bitmask passed to CObex::SuppressAuthenticationHeaderElements");
+ __ASSERT_ALWAYS((!(aSuppressedObexAuthElements > EObexSuppressAllAuthElements)), User::Panic(panicText, KErrArgument));
+
+ iSuppressedObexAuthElements = aSuppressedObexAuthElements;
+
+ };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/OBEXUTIL.CPP Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,189 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <e32std.h>
+#include <obextransportinfo.h>
+#include <obexirtransportinfo.h>
+#include <obexbttransportinfo.h>
+#include <obexusbtransportinfo.h>
+#include "obexcommon.h"
+#include "OBEXUTIL.H"
+#include "obexfaults.h"
+
+
+void IrOBEXUtil::Panic(TObexPanicCode aCode)
+ {
+ User::Panic(KObexPanicCategory, aCode);
+ }
+
+
+void IrOBEXUtil::Fault(TObexFaultCode aCode)
+ {
+ User::Panic(KObexFaultCategory, aCode);
+ }
+
+/**
+Converts aResp to an EPOC error number
+*/
+TInt IrOBEXUtil::EpocError(TUint8 aResp)
+ {
+ switch (aResp)
+ {
+ case ERespContinue:
+ case ERespSuccess:
+ case ERespCreated:
+ case ERespAccepted:
+ return (KErrNone);
+ case ERespBadRequest:
+ case ERespUnauthorized:
+ case ERespForbidden:
+ case ERespNotAcceptable:
+ case ERespMethodNotAllowed:
+ return (KErrArgument);
+ case ERespNotFound:
+ return (KErrNotFound);
+ case ERespTimedOut:
+ return (KErrTimedOut);
+ case ERespConflict:
+ return (KErrInUse);
+ case ERespNotImplemented:
+ return (KErrNotSupported);
+ default:
+ return (KErrIrObexRespBase - aResp);
+ }
+ }
+
+/**
+Returns a TObexTransportInfo created from the received aObexProtocolInfoPtr and aObexProtocolPolicy
+to be used in the transport layer
+*/
+TObexTransportInfo* IrOBEXUtil::CreateTransportInfoL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy)
+ {
+ TObexTransportInfo* transportInfo = NULL;
+
+ if ( aObexProtocolInfoPtr.iTransport == KObexIrTTPProtocol )
+ {
+ transportInfo = new(ELeave) TObexIrTransportInfo;
+ TObexIrProtocolInfo& irProtocolInfo = static_cast<TObexIrProtocolInfo&>(aObexProtocolInfoPtr);
+ static_cast<TObexIrTransportInfo*>(transportInfo)->iAddr = irProtocolInfo.iAddr;
+ static_cast<TObexIrTransportInfo*>(transportInfo)->iClassName = irProtocolInfo.iClassName;
+ static_cast<TObexIrTransportInfo*>(transportInfo)->iAttributeName = irProtocolInfo.iAttributeName;
+ }
+ else if ( aObexProtocolInfoPtr.iTransport == KObexIrTTPProtocolV2 )
+ {
+ transportInfo = new(ELeave) TObexIrV2TransportInfo;
+ TObexIrProtocolInfo& irProtocolInfo = static_cast<TObexIrProtocolInfo&>(aObexProtocolInfoPtr);
+ static_cast<TObexIrV2TransportInfo*>(transportInfo)->iAddr = irProtocolInfo.iAddr;
+ static_cast<TObexIrV2TransportInfo*>(transportInfo)->iClassName = irProtocolInfo.iClassName;
+ static_cast<TObexIrV2TransportInfo*>(transportInfo)->iAttributeName = irProtocolInfo.iAttributeName;
+ static_cast<TObexIrV2TransportInfo*>(transportInfo)->iDiscoverySlots = irProtocolInfo.iDiscoverySlots;
+ static_cast<TObexIrV2TransportInfo*>(transportInfo)->iDiscoveryAttempts = irProtocolInfo.iDiscoveryAttempts;
+ }
+ else if ( aObexProtocolInfoPtr.iTransport == KObexRfcommProtocol )
+ {
+ transportInfo = new(ELeave) TObexBtTransportInfo;
+ TObexBluetoothProtocolInfo& btProtocolInfo = static_cast<TObexBluetoothProtocolInfo&>(aObexProtocolInfoPtr);
+ static_cast<TObexBtTransportInfo*>(transportInfo)->iAddr = btProtocolInfo.iAddr;
+ }
+#ifdef __WINS__
+ else if ( aObexProtocolInfoPtr.iTransport == KObexUsbProtocol || aObexProtocolInfoPtr.iTransport == KObexWin32UsbProtocol )
+#else
+ else if ( aObexProtocolInfoPtr.iTransport == KObexUsbProtocol)
+#endif
+ {
+ transportInfo = new(ELeave) TObexUsbTransportInfo();
+ TObexUsbProtocolInfo& usbTransportInfo = static_cast<TObexUsbProtocolInfo&>(aObexProtocolInfoPtr);
+ static_cast<TObexUsbTransportInfo*>(transportInfo)->iInterfaceStringDescriptor = usbTransportInfo.iInterfaceStringDescriptor;
+ }
+ else if ( aObexProtocolInfoPtr.iTransport == KObexUsbProtocolV2 )
+ {
+ transportInfo = new(ELeave) TObexUsbV2TransportInfo();
+ TObexUsbProtocolInfoV2& usbV2TransportInfo = static_cast<TObexUsbProtocolInfoV2&>(aObexProtocolInfoPtr);
+ static_cast<TObexUsbV2TransportInfo*>(transportInfo)->iInterfaceStringDescriptor = usbV2TransportInfo.iInterfaceStringDescriptor;
+ static_cast<TObexUsbV2TransportInfo*>(transportInfo)->iBandwidthPriority = usbV2TransportInfo.iBandwidthPriority;
+ static_cast<TObexUsbV2TransportInfo*>(transportInfo)->iDmaOnOutEndpoint = usbV2TransportInfo.iDmaOnOutEndpoint;
+ static_cast<TObexUsbV2TransportInfo*>(transportInfo)->iDmaOnInEndpoint = usbV2TransportInfo.iDmaOnInEndpoint;
+ }
+
+ __ASSERT_DEBUG(transportInfo, Fault(EUtilNoTransportInfo));
+ transportInfo->iTransportName = aObexProtocolInfoPtr.iTransport;
+ transportInfo->iReceiveMtu = aObexProtocolPolicy.ReceiveMtu();
+ transportInfo->iTransmitMtu = aObexProtocolPolicy.TransmitMtu();
+ transportInfo->iVersion = KObexTransportInfoVersion0;
+ return transportInfo;
+ }
+
+/**
+Converts aErr to an obex response.
+
+@return aDefault if aErr == KErrNone, else the appriate obex response
+*/
+TObexResponse IrOBEXUtil::ObexResponse (TInt aErr, TObexResponse aDefault)
+ {
+ switch (aErr)
+ {
+ case KErrNone:
+ return (aDefault);
+ case KErrNotFound:
+ case KErrPathNotFound:
+ case KErrUnknown:
+ case KErrBadName:
+ return (ERespNotFound);
+ case KErrNotSupported:
+ return (ERespNotImplemented);
+ case KErrAlreadyExists:
+ case KErrInUse:
+ return (ERespConflict);
+ case KErrAccessDenied:
+ return (ERespUnauthorized);
+ case KErrLocked:
+ return (ERespForbidden);
+ case KErrTimedOut:
+ return (ERespTimedOut);
+ default:
+ {
+ //check if it's one of the Symbian codes which has been set aside for
+ //mapping to an official OBEX code
+ //unfortunately these are not continuous and exist in 4 discrete blocks
+
+ if (( (aErr <= KErrIrObexRespSuccess ) && (aErr >= KErrIrObexRespPartialContent))
+ ||( (aErr <=KErrIrObexRespMultipleChoices) && (aErr >= KErrIrObexRespUseProxy))
+ ||( (aErr<=KErrIrObexRespBadRequest) && (aErr>=KErrIrObexRespHTTPVerNotSupp) )
+ ||( (aErr <= KErrIrObexRespDatabaseFull) && (aErr >= KErrIrObexRespDatabaseLocked)))
+ {
+
+
+ TInt err = aErr * -1;
+
+ err += KErrIrObexRespBase;
+
+
+
+ return ( static_cast<TObexResponse>(err) );
+
+ }
+ //in all other cases the error code isn't understood
+ return (ERespInternalError);
+ }
+ }
+ }
+
+//
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerOperationState.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,253 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+*/
+
+/**
+Called by the state machine when it has moved into the state
+Default action - do nothing and return no error
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::Entry(CObexServerStateMachine& /*aContext*/)
+ {
+ }
+
+/**
+Connection packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket Connect packet
+*/
+void TObexServerOperationState::Connect(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+ {
+ IrOBEXUtil::Fault(EConnectInBadState);
+ }
+
+/**
+Disconnect packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket Disconnect packet
+*/
+void TObexServerOperationState::Disconnect(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+ {
+ IrOBEXUtil::Fault(EDisconnectInBadState);
+ }
+
+/**
+Put packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket Put packet
+*/
+void TObexServerOperationState::Put(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+ {
+ IrOBEXUtil::Fault(EPutInBadState);
+ }
+
+/**
+Get packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket Get packet
+*/
+void TObexServerOperationState::Get(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+ {
+ IrOBEXUtil::Fault(EGetInBadState);
+ }
+
+/**
+SetPath packet to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+@param aPacket SetPath packet
+*/
+void TObexServerOperationState::SetPath(CObexServerStateMachine& /*aContext*/, CObexPacket& /*aPacket*/)
+ {
+ IrOBEXUtil::Fault(ESetPathInBadState);
+ }
+
+/**
+Abort request to be processed
+Default action - fault (event should not happen for this state)
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::Abort(CObexServerStateMachine& /*aContext*/)
+ {
+ IrOBEXUtil::Fault(EAbortInBadState);
+ }
+
+/**
+Transport up notification
+Default action - do nothing or fault (event should not happen for this state)
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::TransportUp(CObexServerStateMachine& /*aContext*/)
+ {
+ __ASSERT_DEBUG(EFalse, IrOBEXUtil::Fault(ETransportUpInBadState));
+ }
+
+/**
+Server Start notification
+Default action - do nothing and return no error
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::Start(CObexServerStateMachine& /*aContext*/)
+ {
+ }
+
+/**
+Reset notification - state machine should go back to the initial (disconnected) state
+Default action - change to Disconnected state
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::Reset(CObexServerStateMachine& aContext)
+ {
+ aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+ }
+
+/**
+Asynchronous notification complete - the Application has return an object for the current operation
+Default action - panic as there is no operation waiting for a notification
+@param aContext Reference to state machine object
+@param aObject Pointer to object returned from the Application
+@panic ENoNotificationToComplete
+*/
+void TObexServerOperationState::RequestNotificationCompleted(CObexServerStateMachine& /*aContext*/, CObexBaseObject* /*aObject*/)
+ {
+ IrOBEXUtil::Panic(ENoNotificationToComplete);
+ }
+
+/**
+Asynchronous notification complete - the Application has return an object for the current operation
+Default action - panic as there is no operation waiting for a notification
+@param aContext Reference to state machine object
+@param aObject Pointer to object returned from the Application
+@panic ENoNotificationToComplete
+*/
+void TObexServerOperationState::RequestNotificationCompleted(CObexServerStateMachine& /*aContext*/, TObexResponse /*aAppResponse*/)
+ {
+ IrOBEXUtil::Panic(ENoNotificationToComplete);
+ }
+
+/**
+Asynchronous notification complete - the Application has return an object for the current operation
+Default action - panic as there is no operation waiting for a notification
+@param aContext Reference to state machine object
+@param aObject Pointer to object returned from the Application
+@panic ENoNotificationToComplete
+*/
+void TObexServerOperationState::RequestCompleteNotificationCompleted(CObexServerStateMachine& /*aContext*/, TObexResponse /*aAppResponse*/)
+ {
+ IrOBEXUtil::Panic(ENoNotificationToComplete);
+ }
+
+
+/**
+Connection notification - an OBEX connection has been made
+Default action - panic. This should not be passed to the state machine in this state.
+@param aContext Reference to state machine object
+*/
+void TObexServerOperationState::ConnectionComplete(CObexServerStateMachine& /*aContext*/)
+ {
+ IrOBEXUtil::Fault(EConnectionCompleteInBadState);
+ }
+
+/**
+A user has requested to override the handling of a request packet.
+@param aContext Reference to state machine object
+@param aResponse Response code to send to Obex Client (this must not be a success code)
+*/
+void TObexServerOperationState::OverrideRequestHandling(CObexServerStateMachine& /*aContext*/, TObexResponse /*aResponse*/)
+ {
+ IrOBEXUtil::Panic(EOverrideRequestHandlingInBadState);
+ }
+
+// Utility functions - common operations performed by states
+
+/**
+Check disconnect packet for the correct connection ID (if required) and disconnect the Client
+If the check is not sucessful, return to the Idle state if there is an OBEX connection
+or the TransportConnected state otherwise
+@param aContext Reference to state machine object
+@param aPacket Disconnect packet
+*/
+/*static*/ void TObexServerOperationState::PerformDisconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ FLOG(_L("OnPacketReceive DisConnect OP code\r\n"));
+ aContext.Owner().SetCurrentOperation(CObex::EOpDisconnect);
+
+ // Check for connection ID before performing disconnect
+ if (aContext.Owner().CheckPacketForConnectionId(aPacket))
+ {
+ aContext.Transport().Send(ERespSuccess);
+ aContext.ChangeState(CObexServerStateMachine::EDisconnecting);
+ }
+ else
+ {
+ // Incorrect connection ID - abandon current operation
+ aContext.Transport().Send(ERespServiceUnavailable);
+ // Target states depends on whether there is a current OBEX connection
+ if (aContext.Owner().GetConnectState() == CObex::EConnObex)
+ {
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ }
+ else
+ {
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ }
+ }
+ }
+
+/**
+End the current operation, sending the given response code to the Client and moving to the Idle state
+@panic ObexFault ERespondAndEndOpWithoutObexConnection if there is no OBEX connection
+@param aContext Reference to state machine object
+@param aResponseCode Response code to send to the Client
+*/
+/*static*/ void TObexServerOperationState::RespondAndEndOperation(CObexServerStateMachine& aContext, TObexResponse aResponseCode)
+ {
+ // This function assumes that there is an OBEX connection, so it goes back to EReady - the assert checks this
+ __ASSERT_DEBUG((aContext.Owner().GetConnectState() == CObex::EConnObex),IrOBEXUtil::Fault(ERespondAndEndOpWithoutObexConnection));
+
+ aContext.Transport().Send(aResponseCode);
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ }
+
+TBool TObexServerOperationState::ValidResponse(TObexResponse /*aResponseCode*/)
+ {
+ return EFalse;
+ }
+
+void TObexServerOperationState::WriteComplete(CObexServerStateMachine& /*aContext*/)
+ {
+ }
+
+/**
+Indicates that a new obex packet is being read. Do nothing in default state.
+*/
+void TObexServerOperationState::ReadActivityDetected(CObexServerStateMachine& /*aContext*/)
+ {
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateDisconnected.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,49 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+Disconnected State
+This is the ground state for the machine: transport is disconnected, operation is EOpIdle
+Machine will move to TransportConnnected state on receiving a TransportUp
+*/
+
+TObexServerStateDisconnected::TObexServerStateDisconnected()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "Disconnected");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateDisconnected::Entry(CObexServerStateMachine& aContext)
+ {
+ aContext.Owner().SetCurrentOperation(CObex::EOpIdle);
+ }
+
+void TObexServerStateDisconnected::TransportUp(CObexServerStateMachine& aContext)
+ {
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ }
+
+void TObexServerStateDisconnected::Reset(CObexServerStateMachine& /*aContext*/)
+ {
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateDisconnecting.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,92 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+#if ( defined __FLOG_ACTIVE && defined __LOG_FUNCTIONS__ )
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+@file
+@internalComponent
+
+Disconnecting State
+In this state, the server has received a (correctly-addressed) disconnect
+request from the client, and placed an asynchronous request on the transport
+to ACK it.
+This state is interested in the completion of that send request so it can (a)
+complete the client's notifications, (b) move to 'transport connected' state
+and (c) pull down the transport.
+*/
+
+TObexServerStateDisconnecting::TObexServerStateDisconnecting()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "Disconnecting");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateDisconnecting::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexBadEvent);
+ }
+
+void TObexServerStateDisconnecting::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexBadEvent);
+ }
+
+void TObexServerStateDisconnecting::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexBadEvent);
+ }
+
+void TObexServerStateDisconnecting::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexBadEvent);
+ }
+
+void TObexServerStateDisconnecting::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexBadEvent);
+ }
+
+void TObexServerStateDisconnecting::Abort(CObexServerStateMachine& aContext)
+ {
+ aContext.Owner().Error(KErrIrObexBadEvent);
+ }
+
+void TObexServerStateDisconnecting::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+ {
+ aContext.Owner().Error(KErrIrObexBadEvent);
+ }
+
+void TObexServerStateDisconnecting::WriteComplete(CObexServerStateMachine& aContext)
+ {
+ LOG_FUNC
+
+ aContext.Notification().ObexDisconnectIndication(KNullDesC8);
+ // ControlledTransportDown() may raise a TransportDown event immediately,
+ // re-entering the state machine, so we need to be in the correct state
+ // (TransportConnected) before the call.
+ // Also need to keep current operation == EOpDisconnect until transport is
+ // happy (which is done in CObex) so ETransportConnected does not set
+ // iCurrentOperation to EOpIdle.
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ aContext.ControlledTransportDown();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateGetOpFinal.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,120 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+Final Get Operation Receive State
+Waiting for reply from server app to an async notification GetCompleteIndication
+
+Any OBEX operation will cause a Protocol Error
+Chaging the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cancel the notification and move the machine to Disconnected
+The NotificationComplete event send the response back to the client and move the state machine to Ready
+*/
+
+TObexServerStateGetOpFinal::TObexServerStateGetOpFinal()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "GetOpFinal");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateGetOpFinal::Entry(CObexServerStateMachine& aContext)
+ {
+ aContext.Notification().GetCompleteIndication();
+ }
+
+void TObexServerStateGetOpFinal::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpFinal::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpFinal::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpFinal::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpFinal::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpFinal::Abort(CObexServerStateMachine& aContext)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpFinal::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpFinal::Reset(CObexServerStateMachine& aContext)
+ {
+ // Cancel notification - if it has not already been activated
+ if (!aContext.IsCallBackActive())
+ {
+ aContext.Notification().CancelIndicationCallback();
+ }
+ aContext.CancelCallBack();
+ aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+ }
+
+void TObexServerStateGetOpFinal::Start(CObexServerStateMachine& /*aContext*/)
+ {
+ // Panic - trying to change interface during wait
+ IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+ }
+
+void TObexServerStateGetOpFinal::RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+ {
+ aContext.SetAppResponse(aAppResponse);
+ aContext.CallBack(TObexServerStateGetOpFinal::ProcessNotification);
+ }
+
+TInt TObexServerStateGetOpFinal::ProcessNotification(TAny* aPtr)
+ {
+ CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+
+ context.Transport().SendPacket().SetOpcode(context.AppResponse());
+ context.Transport().SendPacket().SetFinal();
+ context.Transport().Send();
+
+ context.ChangeState(CObexServerStateMachine::EReady);
+ return KErrNone;
+ }
+
+TBool TObexServerStateGetOpFinal::ValidResponse(TObexResponse aResponseCode)
+ {
+ return (aResponseCode>0 && aResponseCode<=255 && aResponseCode != ERespContinue);
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateGetOpReceiveSpecification.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,107 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+GET Operation Receive Specification State
+This state receives the specification object from the client and transfers to GetOpWaitForUser once the object is received
+A GET, DISCONNECT or ABORT will be processed
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStateGetOpReceiveSpecification::TObexServerStateGetOpReceiveSpecification()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "GetOpReceiveSpecification");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateGetOpReceiveSpecification::Entry(CObexServerStateMachine& aContext)
+ {
+ // Reset specification object
+ if(aContext.SpecObject()->InitReceive() != KErrNone)
+ {
+ aContext.Transport().Send(ERespInternalError);
+ return;
+ }
+ aContext.Owner().SetCurrentOperation(CObex::EOpGet);
+ // Chain on to Get to start receiving specification
+ Get(aContext, aContext.LastReceivedPacket());
+ }
+
+void TObexServerStateGetOpReceiveSpecification::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict and return to Ready
+ RespondAndEndOperation(aContext, ERespConflict);
+ }
+
+void TObexServerStateGetOpReceiveSpecification::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ // Process disconnect
+ PerformDisconnect(aContext, aPacket);
+ }
+
+void TObexServerStateGetOpReceiveSpecification::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespBadRequest and return to Ready
+ RespondAndEndOperation(aContext, ERespBadRequest);
+ }
+
+void TObexServerStateGetOpReceiveSpecification::Get(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ // Process packet and see if specification is complete
+ // Packet contains more headers describing the object to be 'got'
+ if(aContext.SpecObject()->ParseNextReceivePacket(aPacket) == CObexBaseObject::EError)
+ {
+ aContext.Transport().Send(aContext.SpecObject()->GetLastError());
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ return;
+ }
+
+ if(aPacket.IsFinal())
+ {// Time to turn around and start sending our reply
+ aContext.ChangeState(CObexServerStateMachine::EGetOpWaitForUser);
+ }
+ else
+ {
+ aContext.Transport().Send(ERespContinue);
+ }
+ }
+
+void TObexServerStateGetOpReceiveSpecification::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict and return to Ready
+ RespondAndEndOperation(aContext, ERespConflict);
+ }
+
+void TObexServerStateGetOpReceiveSpecification::Abort(CObexServerStateMachine& aContext)
+ {
+ // Send ERespSuccess and return to Ready
+ aContext.Notification().AbortIndication();
+ RespondAndEndOperation(aContext, ERespSuccess);
+ }
+
+void TObexServerStateGetOpReceiveSpecification::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+ {
+ // Send server app response and return to Ready
+ RespondAndEndOperation(aContext, aResponse);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateGetOpSendObject.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,108 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+GET Operation Send State
+This state sends the object to the client and transfers to Ready once the exchange is finished
+A GET, DISCONNECT or ABORT will be processed
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStateGetOpSendObject::TObexServerStateGetOpSendObject()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "GetOpSendObject");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateGetOpSendObject::Entry(CObexServerStateMachine& aContext)
+ {
+ // Chain on to Get() to start sending object
+ Get(aContext, aContext.LastReceivedPacket());
+ }
+
+void TObexServerStateGetOpSendObject::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict and return to Ready
+ RespondAndEndOperation(aContext, ERespConflict);
+ }
+
+void TObexServerStateGetOpSendObject::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ // Process disconnect
+ PerformDisconnect(aContext, aPacket);
+ }
+
+void TObexServerStateGetOpSendObject::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespBadRequest and return to Ready
+ RespondAndEndOperation(aContext, ERespBadRequest);
+ }
+
+void TObexServerStateGetOpSendObject::Get(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ if(!aPacket.IsFinal())
+ {
+ // Raising a Protocol Error will cause a Reset event resulting in a move to Disconnected.
+ // So any code after this call will potentially be executed in a different state
+ aContext.Owner().Error(KErrCommsOverrun);
+ return;
+ }
+
+ // This section prepares the next packet to send, if an error is detected or it is the final packet
+ // the machine is moved to EReady.
+ TInt err = KErrGeneral;
+ if(aContext.TransObject()->PrepareNextSendPacket(aContext.Transport().SendPacket()) == CObexBaseObject::EError ||
+ (err = aContext.Notification().GetPacketIndication()) != KErrNone)
+ {
+ aContext.Transport().SendPacket().Init(IrOBEXUtil::ObexResponse(err, ERespInternalError));
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ }
+ else if(aContext.Transport().SendPacket().IsFinal())
+ {// This is the last packet of the object being returned to client
+ aContext.ChangeState(CObexServerStateMachine::EGetOpFinal);
+ return;
+ }
+ // Send the resultant packet
+ aContext.Transport().SendPacket().SetFinal();
+ aContext.Transport().Send();
+ }
+
+void TObexServerStateGetOpSendObject::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict and return to Ready
+ RespondAndEndOperation(aContext, ERespConflict);
+ }
+
+void TObexServerStateGetOpSendObject::Abort(CObexServerStateMachine& aContext)
+ {
+ // Send ERespSuccess and return to Ready
+ aContext.Notification().AbortIndication();
+ RespondAndEndOperation(aContext, ERespSuccess);
+ }
+
+void TObexServerStateGetOpSendObject::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+ {
+ // Send server app response and return to Ready
+ RespondAndEndOperation(aContext, aResponse);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateGetOpWaitForUser.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,175 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+GET Operation Wait State
+This state issues the Get indication to the Application on entry and then waits for the response.
+
+Any OBEX operation will be cause a Protocol Error
+Chaging the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cancel the notification and move the machine to Disconnected
+The NotificationComplete event will queue a async one-shot to process the returned object, moving the machine to GetOpSendObject
+*/
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KGetWaitCmpt, "getwait");
+
+#define GETWAIT_LOG(str) CObexLog::Write(KGetWaitCmpt, str)
+#else
+#define GETWAIT_LOG(str)
+#endif
+
+
+TObexServerStateGetOpWaitForUser::TObexServerStateGetOpWaitForUser()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "GetOpWaitForUser");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateGetOpWaitForUser::Entry(CObexServerStateMachine& aContext)
+ {
+ // Send notification to the Application
+ aContext.SetTransObject(NULL);
+
+ GETWAIT_LOG(_L8("Upcalling..."));
+ aContext.Notification().GetRequestIndication(aContext.SpecObject());
+ }
+
+void TObexServerStateGetOpWaitForUser::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpWaitForUser::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpWaitForUser::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpWaitForUser::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpWaitForUser::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpWaitForUser::Abort(CObexServerStateMachine& aContext)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpWaitForUser::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateGetOpWaitForUser::Start(CObexServerStateMachine& /*aContext*/)
+ {
+ // Panic - trying to change interface during wait
+ IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+ }
+
+void TObexServerStateGetOpWaitForUser::Reset(CObexServerStateMachine& aContext)
+ {
+ // Cancel notification - if it has not already been activated
+ if (!aContext.IsCallBackActive())
+ {
+ aContext.Notification().CancelIndicationCallback();
+ }
+ aContext.CancelCallBack();
+ aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+ }
+
+void TObexServerStateGetOpWaitForUser::RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject)
+ {
+ aContext.SetTransObject(aObject);
+ aContext.CallBack(TObexServerStateGetOpWaitForUser::ProcessNotification);
+ }
+
+void TObexServerStateGetOpWaitForUser::RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+ {
+ aContext.SetAppResponse(aAppResponse);
+ aContext.CallBack(TObexServerStateGetOpWaitForUser::ProcessErrorNotification);
+ }
+
+/*static*/ TInt TObexServerStateGetOpWaitForUser::ProcessNotification(TAny* aPtr)
+ {
+ // Get hold of the Context and the returned object
+ CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+
+ GETWAIT_LOG(_L8("Process notification"));
+ CObexBaseObject* object = context.TransObject();
+
+ //Check and initialise object, move to GetOpSendObject
+ if (!object)
+ {
+ RespondAndEndOperation(context, ERespForbidden);
+ }
+ else if (object->InitSend(ERespContinue) != KErrNone)
+ {
+ RespondAndEndOperation(context, ERespInternalError);
+ }
+ else
+ {
+ //ConnectionID is compulsory if Target header was used at connection
+ if ( context.Owner().CheckObjectForConnectionId(*(context.SpecObject())))
+ {
+ context.ChangeState(CObexServerStateMachine::EGetOpSendObject);
+ }
+ else //connectionID was incorrect or not received
+ {
+ context.Transport().Send(ERespServiceUnavailable);
+ }
+ }
+ return KErrNone;
+ }
+
+/*static*/ TInt TObexServerStateGetOpWaitForUser::ProcessErrorNotification(TAny* aPtr)
+ {
+ // Get hold of the Context and the returned object
+ CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+
+ RespondAndEndOperation(context, context.AppResponse());
+
+ return KErrNone;
+ }
+
+TBool TObexServerStateGetOpWaitForUser::ValidResponse(TObexResponse aResponseCode)
+ {
+ return (aResponseCode>0 && aResponseCode<=255 && aResponseCode != ERespContinue &&
+ aResponseCode != ERespSuccess && aResponseCode != ERespCreated && aResponseCode != ERespAccepted);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateObexConnecting.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,178 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+OBEX Connecting State
+This state is entered during an OBEX connection attempt. The authentication state machine is
+invoked via ParseConnectPacket and PrepareConnect packet.
+A successful CONNECT will move the machine to Ready.
+A CONNECT requiring a user password will move the machine to WaitForUserPassword
+Other CONNECT results may stay in this state or move the machine to TransportConnected
+A DISCONNECT will be processed
+An ABORT will cause a Protocol Error
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStateObexConnecting::TObexServerStateObexConnecting()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "ObexConnecting");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateObexConnecting::Entry(CObexServerStateMachine& aContext)
+ {
+ // Reset the Connect State Machine
+ aContext.Owner().SetConnectState(CObex::EConnTransport);
+ // Chain on to Connect to process packet
+ Connect(aContext, aContext.LastReceivedPacket());
+ }
+
+void TObexServerStateObexConnecting::Connect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ // Process connect packet
+ // This will return KErrNone if the packet is OK
+ // a positive number if an OBEX error should be returned to the Client
+ // a negative number if a Symbian error should be raised (as a Protocol Error)
+ TInt parseConnectResult = aContext.Owner().ParseConnectPacket(aPacket);
+ if (parseConnectResult == KErrNone)
+ {
+ FLOG(_L("OnPacketReceive ParseConnectPacket succesfull\r\n"));
+ aContext.Transport().SendPacket().Init(CObex::EOpConnect);
+ // PrepareConnectPacket will check the present state and request
+ // Auth, or check Auth as necessary and will return:
+ // An error & connect state set to EWaitForUserInput if a User Password is required
+ // No error and connect state set to EConnObex if the connection was successful
+ // Connect state set to EConnTransport if there is an error packet to send back to the client
+ // Other connect states will return a packet to send and stay in the current state
+ TInt err = aContext.Owner().PrepareConnectPacket(aContext.Transport().SendPacket());
+ if ((err == KErrNone) || (aContext.Owner().GetConnectState() == CObex::EConnTransport)
+ || (aContext.Owner().GetConnectState() == CObex::EWaitForUserInput))
+ {
+ FLOG(_L("OnPacketReceive PrepareConnectPacket SUCCESS\r\n"));
+ // If not waiting for user input, send the resultant packet
+ if ( aContext.Owner().GetConnectState() != CObex::EWaitForUserInput )
+ {
+ aContext.Transport().SendPacket().SetFinal();
+ aContext.Transport().Send();
+ }
+ // Move this (operation) state machine according to result of authentication state machine
+ switch (aContext.Owner().GetConnectState())
+ {
+ case CObex::EConnTransport:
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ break;
+ case CObex::EConnObex:
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ break;
+ case CObex::EWaitForUserInput:
+ aContext.ChangeState(CObexServerStateMachine::EWaitForUserPassword);
+ break;
+ }
+ }
+ else
+ {
+ FTRACE( if (err)
+ {
+ FPrint(_L("OnPacketReceive PrepareConnectPacket FAILED"));
+ }
+ else
+ {
+ FPrint(_L("OnPacketReceive PrepareConnectPacket OK but state is %d"), aContext.Owner().GetConnectState());
+ }
+ );
+ // Raising a Protocol Error will cause a Reset event resulting in a move to Disconnected.
+ // So any code after this call will potentially be executed in a different state.
+ aContext.Owner().Error(err);
+ }
+ }
+ else if (parseConnectResult > 0) // so it's an OBEX error code
+ {
+ FLOG(_L("OnPacketReceive ParseConnectPacket FAILED (OBEX error)\r\n"));
+
+ aContext.Transport().SendPacket().Init(parseConnectResult);
+ TInt rsp = aContext.Owner().PrepareErroredConnectPacket(aContext.Transport().SendPacket());
+ if (rsp == KErrNone)
+ {
+ aContext.Transport().SendPacket().SetFinal();
+ aContext.Transport().Send();
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ }
+ else
+ {
+ aContext.Owner().Error(rsp);
+ }
+ }
+ else // parseConnectResult < 0 so it's a Symbian error code
+ {
+ FLOG(_L("OnPacketReceive ParseConnectPacket FAILED (Symbian error)\r\n"));
+ // Raising a Protocol Error will cause a Reset event resulting in a move to Disconnected.
+ // So any code after this call will potentially be executed in a different state.
+ aContext.Owner().Error(KErrAbort);
+ }
+ }
+
+void TObexServerStateObexConnecting::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ // Process disconnect
+ PerformDisconnect(aContext, aPacket);
+ }
+
+void TObexServerStateObexConnecting::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespBadRequest and return to ETransportConnected
+ aContext.Transport().Send(ERespBadRequest);
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ }
+
+void TObexServerStateObexConnecting::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict and return to ETransportConnected
+ aContext.Transport().Send(ERespConflict);
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ }
+
+void TObexServerStateObexConnecting::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict and return to ETransportConnected
+ aContext.Transport().Send(ERespConflict);
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ }
+
+void TObexServerStateObexConnecting::Abort(CObexServerStateMachine& aContext)
+ {
+ // Send ERespSuccess
+ // Any other response would, according to the spec,
+ // require the Obex client to bring down the transport.
+ // Our attempt is to be resilient if an 'Abort'
+ // is sent erroneously whilst we are in this state.
+ aContext.Transport().Send(ERespSuccess);
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ }
+
+void TObexServerStateObexConnecting::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+ {
+ // Send the server applications response and return to Transport Connected
+ aContext.Transport().Send(aResponse);
+ aContext.ChangeState(CObexServerStateMachine::ETransportConnected);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStatePutOpFinal.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,169 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+Final PUT Operation Receive State
+Waiting for reply from server app to an async notification PutCompleteIndication
+
+Any OBEX operation will cause a Protocol Error
+Chaging the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cancel the notification and move the machine to Disconnected
+The NotificationComplete event send the response back to the client and mvoe the state machine to Ready
+*/
+
+TObexServerStatePutOpFinal::TObexServerStatePutOpFinal()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "PutOpFinalPut");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStatePutOpFinal::Entry(CObexServerStateMachine& aContext)
+ {
+ // Chain on to Put() to start receiving object
+ //return Put(aContext, aContext.LastReceivedPacket());
+ aContext.Notification().PutCompleteIndication();
+ }
+
+void TObexServerStatePutOpFinal::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpFinal::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpFinal::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpFinal::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpFinal::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpFinal::Abort(CObexServerStateMachine& aContext)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpFinal::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpFinal::Start(CObexServerStateMachine& /*aContext*/)
+ {
+ // Panic - trying to change interface during wait
+ IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+ }
+
+// Utility function to handle the optional header set to send at the completion of the Put
+void TObexServerStatePutOpFinal::PrepareFinalResponseHeaderSet(CObexHeader* aHeader, CObexHeaderSet& aHeaderSet, CObexPacket& aPacket)
+ {
+ // We have some additional headers to send, on a best effort
+ // basis...
+ TObexInternalHeader intHeader;
+ aHeaderSet.First();
+ TBool insertedOK=ETrue;
+
+ while(insertedOK && (aHeaderSet.This(aHeader)==KErrNone))
+ {
+ switch(aHeader->Type())
+ {
+ case CObexHeader::EUnicode:
+ intHeader.Set(aHeader->HI(), aHeader->AsUnicode());
+ break;
+
+ case CObexHeader::EByteSeq:
+ intHeader.Set(aHeader->HI(), (const_cast<TUint8*> ((aHeader->AsByteSeq()).Ptr())), (aHeader->AsByteSeq()).Size());
+ break;
+
+ case CObexHeader::EByte:
+ intHeader.Set(aHeader->HI(), aHeader->AsByte());
+ break;
+
+ case CObexHeader::EFourByte:
+ intHeader.Set(aHeader->HI(), aHeader->AsFourByte());
+ break;
+ }
+
+ insertedOK=aPacket.InsertData(intHeader);
+
+ (void)aHeaderSet.Next();
+ }
+ }
+
+void TObexServerStatePutOpFinal::Reset(CObexServerStateMachine& aContext)
+ {
+ // Cancel notification - if it has not already been activated
+ if (!aContext.IsCallBackActive())
+ {
+ aContext.Notification().CancelIndicationCallback();
+ }
+ aContext.CancelCallBack();
+ aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+ }
+
+void TObexServerStatePutOpFinal::RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+ {
+ aContext.SetAppResponse(aAppResponse);
+ aContext.CallBack(TObexServerStatePutOpFinal::ProcessNotification);
+ }
+
+TInt TObexServerStatePutOpFinal::ProcessNotification(TAny* aPtr)
+ {
+ CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+
+ context.Transport().SendPacket().Init(context.AppResponse());
+ context.Transport().SendPacket().SetFinal(); // Because it is
+
+ // Check for additional headers to send
+ if(context.PutFinalResponseHeaderSet())
+ {
+ PrepareFinalResponseHeaderSet( context.GetHeader(),
+ *(context.PutFinalResponseHeaderSet()),
+ context.Transport().SendPacket());
+ // delete the headers now they've been used
+ context.SetPutFinalResponseHeaderSet(NULL);
+ }
+
+ context.Transport().Send();
+ context.ChangeState(CObexServerStateMachine::EReady);
+
+ return KErrNone;
+ }
+
+TBool TObexServerStatePutOpFinal::ValidResponse(TObexResponse aResponseCode)
+ {
+ return (aResponseCode>0 && aResponseCode<=255 && aResponseCode != ERespContinue);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStatePutOpReceiveObject.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,117 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+PUT Operation Receive State
+This state receive the object from the client and transfers to Ready once the exchange is finished
+A PUT, DISCONNECT or ABORT will be processed
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStatePutOpReceiveObject::TObexServerStatePutOpReceiveObject()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "PutOpReceiveObject");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStatePutOpReceiveObject::Entry(CObexServerStateMachine& aContext)
+ {
+ // Chain on to Put() to start receiving object
+ Put(aContext, aContext.LastReceivedPacket());
+ }
+
+void TObexServerStatePutOpReceiveObject::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ // Process disconnect
+ PerformDisconnect(aContext, aPacket);
+ }
+
+void TObexServerStatePutOpReceiveObject::Put(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ //Initialise 'err' to KErrNone:
+ //if ParseNextReceivePacket returns an error, we want
+ //IrOBEXUtil::ObexResponse to return that error unchanged
+ //See: IrOBEXUtil::ObexResponse
+ TInt err = KErrNone;
+
+ // Process Put packet into receive object
+ if(aContext.TransObject()->ParseNextReceivePacket(aPacket) == CObexBaseObject::EError
+ ||(err = aContext.Notification().PutPacketIndication()) != KErrNone)
+ {// Error in receive
+ aContext.Transport().Send(IrOBEXUtil::ObexResponse(err, aContext.TransObject()->GetLastError()));
+ aContext.Notification().ErrorIndication(KErrGeneral);
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ }
+
+ //ConnectionID is compulsory if Target header was used at connection
+ else if ( aContext.Owner().CheckObjectForConnectionId(*(aContext.TransObject())))
+ {
+ if(aPacket.IsFinal())
+ {// Successfully received
+ aContext.ChangeState(CObexServerStateMachine::EPutOpFinal);
+ }
+ else // not final packet
+ {
+ aContext.Transport().Send(ERespContinue);
+ }
+ }
+ else
+ {
+ aContext.Transport().Send(ERespServiceUnavailable); //connectionID was incorrect or not received
+ }
+ }
+
+
+void TObexServerStatePutOpReceiveObject::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict and return to Ready
+ RespondAndEndOperation(aContext, ERespConflict);
+ }
+
+void TObexServerStatePutOpReceiveObject::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict and return to Ready
+ RespondAndEndOperation(aContext, ERespConflict);
+ }
+
+void TObexServerStatePutOpReceiveObject::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict and return to Ready
+ RespondAndEndOperation(aContext, ERespConflict);
+ }
+
+void TObexServerStatePutOpReceiveObject::Abort(CObexServerStateMachine& aContext)
+ {
+ // Send ERespSuccess and return to Ready
+ aContext.Notification().AbortIndication();
+ RespondAndEndOperation(aContext, ERespSuccess);
+ }
+
+void TObexServerStatePutOpReceiveObject::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+ {
+ // Send server app response and return to Ready
+ RespondAndEndOperation(aContext, aResponse);
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStatePutOpWaitForUser.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,159 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+PUT Operation Wait State
+This state issues the Put indication to the Application on entry and then waits for the response.
+
+Any OBEX operation will be cause a Protocol Error
+Chaging the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cancel the notification and move the machine to Disconnected
+The NotificationComplete event will queue a async one-shot to process the returned object, moving the machine to PutOpReceiveObject
+*/
+
+TObexServerStatePutOpWaitForUser::TObexServerStatePutOpWaitForUser()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "PutOpWaitForUser");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStatePutOpWaitForUser::Entry(CObexServerStateMachine& aContext)
+ {
+ // Send notification to the Application
+ aContext.SetTransObject(NULL);
+
+ aContext.Notification().PutRequestIndication();
+ }
+
+void TObexServerStatePutOpWaitForUser::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpWaitForUser::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpWaitForUser::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpWaitForUser::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpWaitForUser::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpWaitForUser::Abort(CObexServerStateMachine& aContext)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpWaitForUser::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+ {
+ // Raise Protocol Error (which will cause a Reset and cancel the notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStatePutOpWaitForUser::Start(CObexServerStateMachine& /*aContext*/)
+ {
+ // Panic - trying to change interface during wait
+ IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+ }
+
+void TObexServerStatePutOpWaitForUser::Reset(CObexServerStateMachine& aContext)
+ {
+ // Cancel notification - if it has not already been activated
+ if (!aContext.IsCallBackActive())
+ {
+ aContext.Notification().CancelIndicationCallback();
+ }
+ aContext.CancelCallBack();
+ aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+ }
+
+void TObexServerStatePutOpWaitForUser::RequestNotificationCompleted(CObexServerStateMachine& aContext, CObexBaseObject* aObject)
+ {
+ aContext.SetTransObject(aObject);
+ aContext.CallBack(TObexServerStatePutOpWaitForUser::ProcessNotification);
+ }
+
+void TObexServerStatePutOpWaitForUser::RequestNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+ {
+ aContext.SetAppResponse(aAppResponse);
+ aContext.CallBack(TObexServerStatePutOpWaitForUser::ProcessErrorNotification);
+ }
+
+/*static*/ TInt TObexServerStatePutOpWaitForUser::ProcessNotification(TAny* aPtr)
+ {
+ // Get hold of the Context and the returned object
+ CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+
+ CObexBaseObject* object = context.TransObject();
+
+ //Check and initialise object, move to PutOpReceiveObject
+ if(!object)
+ {
+ RespondAndEndOperation(context, ERespForbidden);
+ }
+ else if (object->InitReceive() != KErrNone)
+ {
+ RespondAndEndOperation(context, ERespInternalError);
+ }
+ else
+ {
+ context.Owner().SetCurrentOperation(CObex::EOpPut);
+ context.ChangeState(CObexServerStateMachine::EPutOpReceiveObject);
+ }
+
+ return KErrNone;
+ }
+
+/*static*/ TInt TObexServerStatePutOpWaitForUser::ProcessErrorNotification(TAny* aPtr)
+ {
+ // Get hold of the Context and the returned object
+ CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+
+ RespondAndEndOperation(context, context.AppResponse());
+
+ return KErrNone;
+ }
+
+TBool TObexServerStatePutOpWaitForUser::ValidResponse(TObexResponse aResponseCode)
+ {
+ return (aResponseCode>0 && aResponseCode<=255 && aResponseCode != ERespContinue &&
+ aResponseCode != ERespSuccess && aResponseCode != ERespCreated && aResponseCode != ERespAccepted);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateReady.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,95 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+OBEX Ready State
+This is the default state when there is an OBEX connection but no current operation.
+A CONNECT will be answered with an OBEX error code
+A GET will move the machine to GetOpReceiveSpecification
+A PUT will move the machine to PutOpWaitForUser
+A SETPATH will move the machine to SetPathOp
+A DISCONNECT or ABORT will be processed
+*/
+
+TObexServerStateReady::TObexServerStateReady()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "Ready");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateReady::Entry(CObexServerStateMachine& aContext)
+ {
+ aContext.Owner().SetCurrentOperation(CObex::EOpIdle);
+ }
+
+void TObexServerStateReady::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict
+ aContext.Transport().Send(ERespConflict);
+ }
+
+void TObexServerStateReady::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ // Process disconnect
+ PerformDisconnect(aContext, aPacket);
+ }
+
+void TObexServerStateReady::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.ChangeState(CObexServerStateMachine::EPutOpWaitForUser);
+ }
+
+void TObexServerStateReady::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.ChangeState(CObexServerStateMachine::EGetOpReceiveSpecification);
+ }
+
+void TObexServerStateReady::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.ChangeState(CObexServerStateMachine::ESetPathOp);
+ }
+
+void TObexServerStateReady::Abort(CObexServerStateMachine& aContext)
+ {
+ // Send ERespSuccess
+ // Report that we're re-synced
+ aContext.Transport().Send(ERespSuccess);
+ }
+
+void TObexServerStateReady::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+ {
+ // Send response and remain in Ready state
+ aContext.Transport().Send(aResponse);
+ }
+
+
+void TObexServerStateReady::ReadActivityDetected(CObexServerStateMachine& aContext)
+ /*
+ Indicates that a new obex packet is being read.
+ This should only need to be passed up to the user
+ if we are in 'Ready' state.
+ */
+ {
+ aContext.Owner().SignalReadActivity();
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateSetPathOp.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,162 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+#include "obexsetpathdata.h"
+
+/**
+@file
+@internalComponent
+
+SETPATH Operation State
+This state processes the SetPath operation, the SetPathIndication is asynchronous.
+So the state has to wait for RequestCompleteIndicationCallback before sending
+response and transition to the ready state.
+*/
+
+TObexServerStateSetPathOp::TObexServerStateSetPathOp()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "SetPathOp");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateSetPathOp::Entry(CObexServerStateMachine& aContext)
+ {
+ TObexSetPathData data;
+ TBool authChallengePresent = EFalse;
+ CObexPacket& aPacket = aContext.LastReceivedPacket();
+
+ if(!aPacket.ExtractData(data))
+ {
+ aContext.Transport().Send(ERespBadRequest);
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ return;
+ }
+ TInt packetSize = aPacket.PacketSize();
+ // Check Connection ID
+ if (aContext.Owner().CheckPacketForConnectionId(aPacket))
+ {
+ CObex::TSetPathInfo info(data);
+
+ // Search for any name headers
+ TObexInternalHeader header;
+ while(aPacket.ExtractData(header))
+ {
+ if(!info.iNamePresent && header.HI() == TObexInternalHeader::EName && header.GetHVText(info.iName) == KErrNone)
+ {
+ info.iNamePresent = ETrue;
+ }
+ if (header.HI() == TObexInternalHeader::EAuthChallenge)
+ {
+ authChallengePresent = ETrue;
+ }
+ }
+ if (authChallengePresent) // Auth challenge is present, send unauthorized response
+ {
+ aContext.Transport().Send(ERespUnauthorized);
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ }
+ else
+ {
+ //There is no need to add a new state to wait for the RequestCompleteIndicationCallback because there is
+ //no other actions required for SetPath. So just wait in this state.
+ aContext.Notification().SetPathIndication(info, KNullDesC8);
+ }
+
+ }
+ else //bad or missing ConnectionID
+ {
+ aContext.Transport().Send(ERespServiceUnavailable);
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ }
+ }
+
+void TObexServerStateSetPathOp::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateSetPathOp::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateSetPathOp::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateSetPathOp::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateSetPathOp::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateSetPathOp::Abort(CObexServerStateMachine& aContext)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateSetPathOp::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+ {
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateSetPathOp::Start(CObexServerStateMachine& /*aContext*/)
+ {
+ // Panic - trying to change interface during wait
+ IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+ }
+
+void TObexServerStateSetPathOp::Reset(CObexServerStateMachine& aContext)
+ {
+ // Cancel notification - if it has not already been activated
+ if (!aContext.IsCallBackActive())
+ {
+ aContext.Notification().CancelIndicationCallback();
+ }
+ aContext.CancelCallBack();
+ aContext.ChangeState(CObexServerStateMachine::EDisconnected);
+ }
+
+void TObexServerStateSetPathOp::RequestCompleteNotificationCompleted(CObexServerStateMachine& aContext, TObexResponse aAppResponse)
+ {
+ aContext.SetAppResponse(aAppResponse);
+ aContext.CallBack(TObexServerStateSetPathOp::ProcessNotification);
+ }
+
+TInt TObexServerStateSetPathOp::ProcessNotification(TAny* aPtr)
+ {
+ CObexServerStateMachine& context = *static_cast<CObexServerStateMachine*>(aPtr);
+
+ context.Transport().Send(context.AppResponse());
+ context.ChangeState(CObexServerStateMachine::EReady);
+
+ return KErrNone;
+ }
+
+TBool TObexServerStateSetPathOp::ValidResponse(TObexResponse aResponseCode)
+ {
+ return (aResponseCode>0 && aResponseCode<=255 && aResponseCode != ERespContinue);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateTransportConnected.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,83 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+Transport Connected State
+This is the state where there is a transport connect, but no OBEX connection.
+A CONNECT will move the machine to ObexConnecting
+A DISCONNECT will be processed
+An ABORT will cause a Protocol Error
+Any other OBEX operation will be answered with an OBEX error code
+*/
+
+TObexServerStateTransportConnected::TObexServerStateTransportConnected()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "TransportConnected");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateTransportConnected::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ aContext.ChangeState(CObexServerStateMachine::EObexConnecting);
+ }
+
+void TObexServerStateTransportConnected::Disconnect(CObexServerStateMachine& aContext, CObexPacket& aPacket)
+ {
+ // Process disconnect
+ PerformDisconnect(aContext, aPacket);
+ }
+
+void TObexServerStateTransportConnected::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespBadRequest
+ aContext.Transport().Send(ERespBadRequest);
+ }
+
+void TObexServerStateTransportConnected::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict
+ aContext.Transport().Send(ERespConflict);
+ }
+
+void TObexServerStateTransportConnected::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Send ERespConflict
+ aContext.Transport().Send(ERespConflict);
+ }
+
+void TObexServerStateTransportConnected::Abort(CObexServerStateMachine& aContext)
+ {
+ // Send ERespSuccess
+ // Any other response would, according to the spec,
+ // require the Obex client to bring down the transport.
+ // Our attempt is to be resilient if an 'Abort'
+ // is sent erroneously whilst we are in this state.
+ aContext.Transport().Send(ERespSuccess);
+ }
+
+void TObexServerStateTransportConnected::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse aResponse)
+ {
+ aContext.Transport().Send(aResponse);
+ // no need to change state, it's just as if the packet never arrived.
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/TObexServerStateWaitForUserPassword.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,92 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
+#include "obexserverstatemachine.h"
+
+/**
+@file
+@internalComponent
+
+CONNECT Operation Wait State
+This waits for the authentication state machine to receive a password from the user (CObexServer::UserPasswordL) which is indicated by ConnectionComplete
+
+Any OBEX operation will be cause a Protocol Error (which will then cause a reset event)
+Changing the MObexServerNotifyAsync via CObexServer::Start() will cause a Panic
+A Reset event (Protocol Error, Server Stop, Transport Down) will cause a transition to Disconnected
+*/
+
+TObexServerStateWaitForUserPassword::TObexServerStateWaitForUserPassword()
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KName, "WaitForUserPassword");
+ iName = KName;
+#endif
+ }
+
+void TObexServerStateWaitForUserPassword::Connect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (no way to cancel the password request notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateWaitForUserPassword::Disconnect(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (no way to cancel the password request notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateWaitForUserPassword::Put(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (no way to cancel the password request notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateWaitForUserPassword::Get(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (no way to cancel the password request notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateWaitForUserPassword::SetPath(CObexServerStateMachine& aContext, CObexPacket& /*aPacket*/)
+ {
+ // Raise Protocol Error (no way to cancel the password request notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateWaitForUserPassword::Abort(CObexServerStateMachine& aContext)
+ {
+ // Raise Protocol Error (no way to cancel the password request notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateWaitForUserPassword::OverrideRequestHandling(CObexServerStateMachine& aContext, TObexResponse /*aResponse*/)
+ {
+ // Raise Protocol Error (no way to cancel the password request notification)
+ aContext.Owner().Error(KErrIrObexPacketDuringWait);
+ }
+
+void TObexServerStateWaitForUserPassword::Start(CObexServerStateMachine& /*aContext*/)
+ {
+ // Panic - trying to change interface during wait
+ IrOBEXUtil::Panic(EChangeInterfaceDuringWait);
+ }
+
+void TObexServerStateWaitForUserPassword::ConnectionComplete(CObexServerStateMachine& aContext)
+ {
+ // Move to Ready
+ aContext.ChangeState(CObexServerStateMachine::EReady);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/authentication.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,97 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <hash.h>
+#include <e32math.h>
+#include <obex.h>
+#include "authentication.h"
+
+_LIT8(KColonCharacter, ":");
+
+CObexAuthenticator* CObexAuthenticator::NewL()
+ {
+ CObexAuthenticator* s = new(ELeave) CObexAuthenticator;
+ CleanupStack::PushL(s);
+ s->ConstructL();
+ CleanupStack::Pop();
+ return s;
+ }
+
+void CObexAuthenticator::ConstructL()
+ {
+ iMD5 = CMD5::NewL();
+ }
+
+CObexAuthenticator::CObexAuthenticator()
+ {
+ TTime time;
+ time.UniversalTime();
+ iSeed = time.Int64();
+ }
+
+CObexAuthenticator::~CObexAuthenticator()
+ {
+ delete iMD5;
+ }
+
+TInt CObexAuthenticator::GenerateNonce(TDes8& aNonce)
+ {
+ TTime time;
+ time.UniversalTime();
+
+ TInt64 randomNumber = Math::Rand(iSeed);
+ randomNumber <<= 32;
+ randomNumber += Math::Rand(iSeed);
+
+ TBuf8<33> key;
+ key.Zero();
+ key.AppendNum(time.Int64(), EHex);
+ key.Append(_L8(":"));
+ key.AppendNum(randomNumber, EHex);
+
+ iMD5->Reset();
+ aNonce.Append(iMD5->Hash(key));
+ return KErrNone;
+ }
+
+void CObexAuthenticator::GenerateResponseL(const TDesC8& aPasswd, const TNonce& aNonce, TRequestDigest& aRequestDigest)
+ {
+ //work out the length of buffer we need
+ TInt buflen = aNonce.Length() + KColonCharacter().Length() + aPasswd.Length();
+ HBufC8* buf = HBufC8::NewLC(buflen);
+ TPtr8 ptr = buf->Des();
+ ptr.Zero();
+ ptr.Append(aNonce);
+ ptr.Append(KColonCharacter);
+ ptr.Append(aPasswd);
+ iMD5->Reset();
+ aRequestDigest.Append(iMD5->Hash(*buf));
+
+ CleanupStack::PopAndDestroy();//buf
+ }
+
+void CObexAuthenticator::ChallengeResponseL(const TDesC8& aPasswd, const TNonce& aNonce, const TRequestDigest& aRequestDigest)
+ {
+ TRequestDigest digest;
+ digest.Zero();
+ GenerateResponseL(aPasswd, aNonce, digest);
+ if (digest != aRequestDigest)
+ User::Leave(KErrAccessDenied);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexasyncfilewriter.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,280 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <f32file.h>
+#include "obexasyncfilewriter.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+//
+// Panic category for CObexAsyncFileWriter
+//
+_LIT(KObexAsyncFileWriterPanic, "Obex-AFW");
+
+/**
+Panic codes for CObexAsyncFileWriter
+
+@internalComponent
+@released
+*/
+enum TAsyncObexFileWriterPanic
+ {
+ /** Null buffer pointer */
+ ENullBufferPointer
+ };
+
+//
+// Implementation of CObexAsyncFileWriter
+//
+
+/**
+Factory function
+
+Note that we return a pointer to the interface class, so
+that this class can only be used through this interface.
+This class in an implementation of a strategy as part of
+a Strategy pattern. CObexSyncFileWriter provides an
+alternative strategy implementation, with CObexBufObject
+as the context for these strategies.
+
+@see MObexFileWriter
+@see CObexSyncFileWriter
+@see CObexBufObject
+
+@internalComponent
+@released
+
+@param aFile The file we're writing to
+@return An MObexFileWriter for writing to file
+*/
+MObexFileWriter* CObexAsyncFileWriter::NewL(RFile& aFile)
+ {
+ CObexAsyncFileWriter* self = new(ELeave) CObexAsyncFileWriter(aFile);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+Constructor
+
+@internalComponent
+@released
+
+@param aFile The file we're writing to
+*/
+CObexAsyncFileWriter::CObexAsyncFileWriter(RFile& aFile)
+ : CActive(EPriorityStandard), iFile(aFile), iBufPtr(NULL, 0)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+/**
+2nd phase constructor
+
+@internalComponent
+@released
+*/
+void CObexAsyncFileWriter::ConstructL()
+ {
+ }
+
+/**
+AO cancellation
+
+@internalComponent
+@released
+*/
+void CObexAsyncFileWriter::DoCancel()
+ {
+ iFile.Flush();
+ }
+
+/**
+AO request completion
+
+@internalComponent
+@released
+*/
+void CObexAsyncFileWriter::RunL()
+ {
+ // Just ignore completions; the status is picked up next time
+ // a service function is called
+ }
+
+/**
+Normal asynchronous write to file
+
+@internalComponent
+@released
+
+@param aPos The file position
+@param aBuf The buffer we're to write. We use this buffer by copying the pointer
+ and return the buffer we previously wrote to the caller by updating
+ the pointer. If an error occurs, the buffers are not swapped and
+ the pointer is not updated. Note that this class never owns any
+ buffers and that passing a buffer to this function does not imply a
+ transfer of ownership.
+@return Symbian OS error code
+*/
+TInt CObexAsyncFileWriter::Write(TInt aPos, CBufBase*& aBuf)
+ {
+ __ASSERT_ALWAYS(aBuf, PANIC(KObexAsyncFileWriterPanic, ENullBufferPointer));
+
+ // If last write to file has not completed...
+ if (IsActive())
+ {
+ // wait for it to complete
+ User::WaitForRequest(iStatus);
+
+ // if we had an error on the last write
+ if (iStatus.Int())
+ {
+ // Signal ourselves again with the error
+ TRequestStatus* status = &iStatus;
+ User::RequestComplete(status, iStatus.Int());
+ // and then de-activate ourselves by cancelling
+ Cancel();
+ }
+ // if we didn't have an error on the last write,
+ // we've consumed the completion of the write and
+ // hence are still active
+ }
+
+ if (!iStatus.Int())
+ // if the last write completed successfully...
+ {
+ // Swap our and the caller's pointers to show we
+ // have swapped which buffers we are using. Note
+ // that the ownership of the buffers is not changed
+ // by this and the caller must deallocate any buffers
+ // it owns which are passed to this function.
+ CBufBase* buf = iBuffer;
+ iBuffer = aBuf;
+ aBuf = buf;
+
+ // Set up the descriptor to be passed to the file write
+ iBufPtr.Set(iBuffer->Ptr(0));
+
+ // We'll need to be active to service another write
+ if (!IsActive())
+ {
+ SetActive();
+ }
+
+ // kick off writing the next block
+ iFile.Write(aPos, iBufPtr, iStatus);
+
+ // and we're happy...
+ return KErrNone;
+ }
+ else
+ // the last write did not complete successfully
+ {
+ // Signal Obex error
+ return iStatus.Int();
+ }
+
+ }
+
+/**
+Final, synchronous write to file
+
+@internalComponent
+@released
+
+@param aPos The file position
+@param aBuf The buffer we're to write. We use this buffer by copying the pointer
+ and return the buffer we previously wrote to the caller by updating
+ the pointer. If an error occurs, the buffers are not swapped and
+ the pointer is not updated. Note that this class never owns any
+ buffers and that passing a buffer to this function does not imply a
+ transfer of ownership.
+@param aLength The amount of the buffer to write
+@return Symbian OS error code
+*/
+TInt CObexAsyncFileWriter::FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength)
+ {
+ __ASSERT_ALWAYS(aBuf, PANIC(KObexAsyncFileWriterPanic, ENullBufferPointer));
+
+ // If last write to file has not completed...
+ if (IsActive())
+ {
+ // wait for it to complete
+ User::WaitForRequest(iStatus);
+
+ // Signal ourselves again with the request status
+ TRequestStatus* status = &iStatus;
+ User::RequestComplete(status, iStatus.Int());
+
+ // and then de-activate ourselves by cancelling
+ Cancel();
+ }
+
+ // if the last write completed successfully...
+ if (!iStatus.Int())
+ {
+ // Swap our and the caller's pointers to show we
+ // have swapped which buffers we are using. Note
+ // that the ownership of the buffers is not changed
+ // by this and the caller must deallocate any buffers
+ // it owns which are passed to this function.
+ CBufBase* buf = iBuffer;
+ iBuffer = aBuf;
+ aBuf = buf;
+
+ // Set up the descriptor to be passed to the file write
+ iBufPtr.Set(iBuffer->Ptr(0));
+ iBufPtr.SetLength(aLength);
+
+ // write the final block and return the error
+ TInt err = iFile.Write(aPos, iBufPtr);
+ if (err == KErrNone)
+ {
+ //flush the buffer, commit the write
+ return iFile.Flush();
+ }
+ else
+ {
+ return err;
+ }
+ }
+ else
+ // the last write did not complete successfully
+ {
+ // Signal Obex error
+ return iStatus.Int();
+ }
+ }
+
+/**
+Destructor
+
+@internalComponent
+@released
+*/
+CObexAsyncFileWriter::~CObexAsyncFileWriter()
+ {
+ Cancel();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexauthchallengehandler.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,33 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+*/
+
+#include <obexbase.h>
+
+/**
+This virtual function allows the M- classes to be extended in future in a binary
+compatible way by providing a method that clients can override in future to
+allow extra callbacks to be made via aObject.
+*/
+EXPORT_C void MObexAuthChallengeHandler::MOACH_ExtensionInterfaceL(TUid /*aInterface*/, void*& aObject)
+ {
+ aObject = NULL;
+ }
+
+// EOF
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexclient.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,1486 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <charconv.h>
+#include <utf.h>
+#include <obex.h>
+#include <obextransportinfo.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include <obex/internal/obextransportconstants.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexpacket.h>
+#include "logger.h"
+#include "obexsetpathdata.h"
+#include "OBEXUTIL.H"
+#include "obexheaderutil.h"
+#include "authentication.h"
+#include "obexpacketsignaller.h"
+#include "obexpackettimer.h"
+#include "obexnotifyhandlerclient.h"
+#include "obexerrorengine.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+// Constant used to identify if the last received response code field
+// has been populated (i.e., if the first response has been received
+// from the OBEX server). The response code field is only 7 bits (+ the
+// 'final bit') so the use of this 16 bit number will ensure the value
+// for KUnpopulatedResponseCode never overlaps with an actual code.
+const static TUint16 KUnpopulatedResponseCode = 0xffff;
+
+// For debug builds check that when an underlying error is set
+// it has not already been set since the start of the client operation
+// and check that a last error has been set when the operation completes.
+#define SET_LAST_ERROR(_error) __ASSERT_DEBUG(!iIsLastErrorSet, IrOBEXUtil::Fault(ELastErrorSetTwice)); iErrorEngine->SetLastError(CObexErrorEngine::_error); iIsLastErrorSet = ETrue
+#define CHECK_LAST_ERROR_IS_SET __ASSERT_DEBUG(iIsLastErrorSet, IrOBEXUtil::Fault(ELastErrorNotSet)); iIsLastErrorSet = EFalse
+
+
+// Constructor - set initial values
+CObexClient::CObexClient() : CObex()
+ {
+ iCurrentOperation = EOpIdle;
+ iConnectionID = KConnIDInvalid;
+ iLastReceivedResponseOpcode = static_cast<TObexResponse>(KUnpopulatedResponseCode);
+ }
+
+void CObexClient::ConstructL(TObexTransportInfo& aObexTransportInfo)
+ {
+ CObex::ConstructL(aObexTransportInfo);
+ iNotifyHandler = new(ELeave)CObexNotifyHandlerClient(*this);
+ iTransportController->SetOwner(*iNotifyHandler);
+
+ // iHeaderSet is used to store headers received in Put Response
+ iHeaderSet = CObexHeaderSet::NewL();
+ iHeader = CObexHeader::NewL();
+ iPacketProcessSignaller = CObexPacketSignaller::NewL();
+ iErrorEngine = CObexErrorEngine::NewL();
+ iPacketTimer = CObexPacketTimer::NewL(*this);
+ }
+
+/** Destructor.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexClient::~CObexClient()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ Error(KErrCompletion);
+ delete iHeader;
+ delete iHeaderSet;
+ delete iPacketProcessSignaller;
+ delete iNotifyHandler;
+ delete iErrorEngine;
+ delete iPacketTimer;
+ }
+
+/** A call back from the the service with the password required for use with generating
+the challenge response.
+
+@param aPassword Password
+
+@leave KErrNotReady if this function is not called from a MObexAuthChallengeHandler::GetUserPasswordL callback.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::UserPasswordL(const TDesC& aPassword)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ //now have a password, get a nonce, and get it hashed then reply
+ FLOG(_L("CObexClient::UserPasswordL\n\r"));
+ if (GetConnectState() == EWaitForUserInput)
+ {
+ PrepareChallResponseL( aPassword);
+
+ TObexInternalHeader hdr;
+ hdr.Set(TObexInternalHeader::EAuthResponse, CONST_CAST(TUint8*, iOutgoingChallResp.Ptr()), iOutgoingChallResp.Size());
+ FLOG(_L("CObexClient::UserPasswordL EAuth heaqder added\n\r"));
+ if(iTransportController->SendPacket().InsertData(hdr))
+ {
+ SetConnectState(EWaitForFinalResponse);
+ iTransportController->SendPacket().SetFinal();
+ SendRequestPacket();
+ FLOG(_L("CObexClient::UserPasswordL packet sent\n\r"));
+
+ }
+ else
+ {
+ LEAVEIFERRORL(KErrGeneral);
+ }
+ }
+ else
+ {
+ LEAVEIFERRORL(KErrNotReady);
+ }
+ }
+
+/** Allocates and constructs a new OBEX client object.
+
+The received protocol information object, aObexProtocolInfoPtr, specifies the transport protocol to use:
+For the standard transports the following are used, TObexIrProtocolInfo for IrDA, TObexBluetoothProtocolInfo
+for Bluetooth, TObexUsbProtocolInfo for USB.
+
+@param aObexProtocolInfoPtr Protocol information object describing the transport to use
+@return New OBEX client object
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexClient* CObexClient::NewL(TObexProtocolInfo& aObexProtocolInfoPtr)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ TObexProtocolPolicy defaultProtocolPolicy; // no packet sizing policy specified, so use default
+ TObexTransportInfo* transportInfo = IrOBEXUtil::CreateTransportInfoL(aObexProtocolInfoPtr, defaultProtocolPolicy);
+ CleanupStack::PushL(transportInfo);
+ CObexClient* client = CObexClient::NewL(*transportInfo);
+ CleanupStack::PopAndDestroy(transportInfo);
+ return client;
+ }
+
+/** Allocates and constructs a new OBEX client object with packet sizing information.
+
+The received protocol information object, aObexProtocolInfoPtr, specifies the transport protocol to use:
+For the standard transports the following are used, TObexIrProtocolInfo for IrDA, TObexBluetoothProtocolInfo
+for Bluetooth, TObexUsbProtocolInfo for USB.
+
+The aObexProtocolPolicy parameter specifies the packet sizing policy for this OBEX object.
+
+@param aObexProtocolInfoPtr Protocol information object describing the transport to use
+@param aObexProtocolPolicy Protocol policy object specifying the packet sizes to use
+@return New OBEX client object
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexClient* CObexClient::NewL(TObexProtocolInfo& aObexProtocolInfoPtr, TObexProtocolPolicy& aObexProtocolPolicy)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ TObexTransportInfo* transportInfo = IrOBEXUtil::CreateTransportInfoL(aObexProtocolInfoPtr, aObexProtocolPolicy);
+ CleanupStack::PushL(transportInfo);
+ CObexClient* client = CObexClient::NewL(*transportInfo);
+ CleanupStack::PopAndDestroy(transportInfo);
+ return client;
+ }
+
+/** Allocates and constructs a new OBEX client object with packet sizing information.
+
+The received transport information object, aObexTransportInfo, specifies the transport protocol packet sizes to use:
+For the standard transports the following are used, TObexIrProtocolInfo for IrDA, TObexBluetoothProtocolInfo
+for Bluetooth, TObexUsbProtocolInfo for USB.
+
+@param aObexTransportInfo Transport information object describing the transport and packet sizes to use
+@return New OBEX client object
+
+@capability WriteDeviceData If the TObexIrV3TransportInfo is passed as the argument
+ and the associated name is valid.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexClient* CObexClient::NewL(TObexTransportInfo& aObexTransportInfo)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexClient* self = new(ELeave) CObexClient();
+ CleanupStack::PushL(self);
+ self->ConstructL(aObexTransportInfo);
+ CleanupStack::Pop(self);
+ return(self);
+ }
+
+/** OBEX CONNECT operation to any available remote machine, specifying an object
+to pass.
+
+@param aObject OBEX object to pass to the remote machine
+@param aStatus Asynchronous status word. On completion, KErrNone if it was
+successful, or a system-wide error code
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Connect(CObexBaseObject& aObject, TRequestStatus& aStatus)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(!AlreadyActive(aStatus))
+ {
+ FLOG(_L("CObexClient::Connect no password but some header data\r\n"));
+ EmptyHeaderSet();
+ iChallenge = EFalse;
+ OBEX_TRAP(Error, ClientCommandL(EOpConnect, static_cast<TAny*>(&aObject), aStatus));
+ }
+ }
+
+/** OBEX CONNECT operation to any available remote machine, specifying an object
+to pass and a password.
+
+@param aObject OBEX object to pass to the remote machine
+@param aPassword Password to access remote machine
+@param aStatus Asynchronous status word. On completion, KErrNone if it was
+successful, or a system-wide error code
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::ConnectL(CObexBaseObject& aObject, const TDesC& aPassword,
+ TRequestStatus& aStatus)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(!AlreadyActive(aStatus))
+ {
+ FLOG(_L("CObexClient::Connect with password and some header info\r\n"));
+ EmptyHeaderSet();
+ delete iChallPassword;
+ iChallPassword = NULL;
+ iChallPassword = HBufC8::NewL(aPassword.Size());
+ TPtr8 ptr = iChallPassword->Des();
+ CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr, aPassword);
+ iChallenge = ETrue;
+ OBEX_TRAP(Error, ClientCommandL(EOpConnect, static_cast<TAny*>(&aObject), aStatus));
+ }
+ }
+
+
+/** OBEX CONNECT operation to any available remote machine, specifying a password.
+
+@param aPassword Password to access remote machine
+@param aStatus On completion, KErrNone if it was successful, or a system-wide
+error code
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::ConnectL(const TDesC& aPassword, TRequestStatus& aStatus)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(!AlreadyActive(aStatus))
+ {
+ FLOG(_L("CObexClient::Connect with password but no header info\r\n"));
+ EmptyHeaderSet();
+ delete iChallPassword;
+ iChallPassword = NULL;
+ iChallPassword = HBufC8::NewL(aPassword.Length());
+ TPtr8 ptr = iChallPassword->Des();
+ CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr, aPassword);
+ iChallenge = ETrue;
+ OBEX_TRAP(Error, ClientCommandL(EOpConnect, NULL, aStatus));
+ }
+ }
+
+/** OBEX CONNECT operation to any available remote machine.
+
+@param aStatus Asynchronous status word. On completion, KErrNone if it was
+successful, or a system-wide error code
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Connect(TRequestStatus& aStatus)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(!AlreadyActive(aStatus))
+ {
+ FLOG(_L("\tno password no header"));
+ EmptyHeaderSet();
+ iChallenge = EFalse;
+ OBEX_TRAP(Error, ClientCommandL(EOpConnect, NULL, aStatus));
+ }
+ }
+
+/** OBEX DISCONNECT operation.
+
+This terminates the OBEX connection, and closes the transport on receiving
+any response from the server.
+
+@param aStatus Asynchronous status word. On completion, KErrNone on normal
+disconnection, or KErrDisconnected if the server dropped the transport before
+sending an OBEX response (which is valid behaviour).
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Disconnect(TRequestStatus& aStatus)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(!AlreadyActive(aStatus))
+ {
+ FLOG(_L("CObexClient::Disconnect\r\n"));
+ EmptyHeaderSet();
+ OBEX_TRAP (Error, ClientCommandL(EOpDisconnect, NULL, aStatus));
+ }
+ }
+
+/** OBEX PUT operation.
+
+Any valid header that is also present in aObject’s header mask will be sent
+to the server, along with the object body specified by the implementation
+of aObject.
+
+@param aObject OBEX object to put
+@param aStatus Asynchronous status word. On completion, KErrNone if the server
+accepted the object and received it fully, or the appropriate file error if
+the data file could not be opened
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Put(CObexBaseObject& aObject, TRequestStatus& aStatus)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(!AlreadyActive(aStatus))
+ {
+ FLOG(_L("\tnot already active"));
+ EmptyHeaderSet();
+ OBEX_TRAP(Error, ClientCommandL(EOpPut, static_cast<TAny*>(&aObject), aStatus));
+ }
+ }
+
+/** OBEX GET operation.
+
+The caller specifies in aObject the headers to send to the server to specify
+the object to get: normally just a name is expected. If the server can serve
+the request, the object it returns will be loaded into aObject on completion.
+All headers returned by the server that are also allowed by the object’s
+header mask will be loaded into the relevant attributes of aObject. Any object
+body is stored according to the implementation type of the CObexBaseObject
+passed.
+
+@param aObject OBEX object to get; on completion, the retrieved object
+@param aStatus Asynchronous status word. On completion, KErrNone if the server
+passed back an OBEX object, or the appropriate file error if the data file
+could not be opened
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Get(CObexBaseObject& aObject, TRequestStatus& aStatus)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(!AlreadyActive(aStatus))
+ {
+ FLOG(_L("CObexClient::Get\r\n"));
+ EmptyHeaderSet();
+ OBEX_TRAP(Error, ClientCommandL(EOpGet, static_cast<TAny*>(&aObject), aStatus));
+ }
+ }
+
+/** OBEX SETPATH operation.
+
+This changes the remote device's current path.
+
+@param aPathInfo Information to send in the SETPATH command. If you do not
+which to send a name, make sure CObex::TSetPathInfo::iNamePresent is set to
+false.
+@param aStatus Asynchronous status word. On completion, KErrNone if successful,
+or a system-wide error code
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::SetPath(TSetPathInfo& aPathInfo, TRequestStatus& aStatus)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(!AlreadyActive(aStatus))
+ {
+ FLOG(_L("CObexClient::SetPath\r\n"));
+ EmptyHeaderSet();
+ OBEX_TRAP(Error, ClientCommandL(EOpSetPath, static_cast<TAny*>(&aPathInfo), aStatus));
+ }
+ }
+
+/** OBEX ABORT operation.
+
+The function sends the OBEX abort command to the remote machine if a multi-packet
+operation (i.e. PUT or GET) is in progress. An operation in progress will
+complete with KErrAbort.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::Abort()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(iPendingRequest &&(iCurrentOperation == EOpPut
+ || iCurrentOperation == EOpGet || iCurrentOperation == EOpGetResponse))
+ {
+ // We have two phase abort, async. abort request, followed by async. response
+ // To achive this without extra members we use extra operations in TOperation
+ // EOpAbortNoFBit for the asynchronous request
+ // EOpAbort for waiting for the response
+ iCurrentOperation = EOpAbortNoFBit;
+ }
+ }
+
+/**
+This function can be called following the successful completion of a Put,
+and will return a reference to a CObexHeaderSet containing all the headers
+that were contained in the final Put response packet returned from the
+peer Obex server.
+
+The headers in the header set will be deleted by any subsequent call to
+CObexClient functions that trigger Obex commands (ie. Connect, Disconnect,
+Put, Get, SetPath).
+
+The reference should not be retained beyond the end of the lifetime of the
+CObexClient object.
+
+@publishedAll
+@released
+
+@return const reference to a Headerset containing headers returned in final
+Put response packet.
+*/
+EXPORT_C const CObexHeaderSet& CObexClient::GetPutFinalResponseHeaders()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return *iHeaderSet;
+ }
+
+/** Sets a final packet observer.
+
+This replaces any previous observer. The observer will receive a callback
+when a final packet for a put or get request begins to be sent and
+another when the send completes. Although the start and finish callbacks
+are guaranteed to be in order, no guarantees are made about the ordering
+with respect to the completion of the put or get request.
+
+This does not transfer ownership.
+
+@publishedAll
+@released
+@param aObserver The observer to receive packet process events. This may
+ be NULL.
+*/
+EXPORT_C void CObexClient::SetFinalPacketObserver(MObexFinalPacketObserver* aObserver)
+ {
+ iPacketProcessSignaller->SetFinalPacketObserver(aObserver);
+ }
+
+/** Get last server response code
+This method returns the last received OBEX response code.
+The method must not be called prior to a response notification being received by the
+client application. If the method is called a panic will be raised.
+
+@return The last received OBEX response code.
+@panic ENoResponseCodeToReturn Panics if the method is called prior to a response being received from the OBEX server.
+@publishedAll
+@released
+*/
+EXPORT_C TObexResponse CObexClient::LastServerResponseCode() const
+ {
+ LOG_LINE
+ LOG_FUNC
+ // If the last received response code has not been set (i.e., no response has been received) then panic
+ // the client.
+ __ASSERT_ALWAYS(iLastReceivedResponseOpcode != KUnpopulatedResponseCode, IrOBEXUtil::Panic(ENoResponseCodeToReturn));
+ return iLastReceivedResponseOpcode;
+ }
+
+/** Sets the Command Idle Time-out.
+
+This function sets the timer period to be observed during the progress of
+all OBEX commands. If the OBEX server does not respond within the set period
+the current OBEX command will be completed with an error of KErrIrObexRespTimedOut
+and the transport will be disconnected.
+
+Setting a time-out value of 0, all OBEX commands will be allowed to continue
+indefinitely.
+
+@param aTimeOut The time-out period in Microseconds.
+@publishedAll
+@released
+*/
+EXPORT_C void CObexClient::SetCommandTimeOut(TTimeIntervalMicroSeconds32 aTimeOut)
+ {
+ LOG_LINE
+ LOG_FUNC
+ iCmdTimeOutDuration = aTimeOut;
+ }
+
+TBool CObexClient::AlreadyActive(TRequestStatus& aStatus)
+//can't do more than one request at atime
+ {
+ if(iPendingRequest)
+ {
+ TRequestStatus* tempStatus = &aStatus;
+ User::RequestComplete(tempStatus,KErrAccessDenied);
+ return ETrue;
+ }
+ return EFalse;
+ }
+
+void CObexClient::ResetConnectionID()
+ {
+ iConnectionID = KConnIDInvalid;
+ iConnectionIdSet = EFalse;
+ }
+
+void CObexClient::SetConnectionID(TUint32 aConnectionID)
+ {
+ iConnectionID = aConnectionID;
+ iConnectionIdSet = ETrue;
+ }
+
+void CObexClient::ClientCommandL(TOperation aOp, TAny* aParam, TRequestStatus& aStatus)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // Note: Function Calls to this method must be enclosed with an if statement utilising
+ // CObexClient::AlreadyActive
+
+ SetRequest(aStatus, aOp);
+ if(aOp != EOpConnect &&(GetConnectState() != EConnObex || iTransportController == NULL))
+ {
+ SET_LAST_ERROR(EDisconnected);
+ LEAVEIFERRORL(KErrDisconnected);
+ }
+
+ switch(aOp)
+ {
+ case EOpConnect:
+ {
+ switch(GetConnectState())
+ {
+ case EConnIdle:
+ {
+ // Don t start the Packet timer, It will be done once the Transport is up(see :onTransportUp)
+ ResetConnectionID(); //set connection ID to invalid and flag to EFalse
+ iCurrentObject = static_cast<CObexBaseObject*>(aParam);
+ TRAPD(err, iTransportController->ConnectL());
+ if (err != KErrNone)
+ {
+ SET_LAST_ERROR(ETransportUpFailed);
+ LEAVEIFERRORL(err);
+ }
+ }
+ break;
+ case EConnTransport:
+ iCurrentObject = static_cast<CObexBaseObject*>(aParam);
+ //Transport is already connected just do the connection
+ //Previously TransportUp was called. However the transport is already connected
+ //thus the only required actions are the following.
+ OnTransportUp();
+ iTransportController->Receive();
+ break;
+ default:
+ SET_LAST_ERROR(EAlreadyConnected);
+ CompleteRequest(KErrAlreadyExists);
+ }
+ }
+ break;
+ case EOpDisconnect:
+ {
+ iTransportController->SendPacket().Init(TUint8(EOpDisconnect));
+ iTransportController->SendPacket().SetFinal();
+
+ // Insert the ConnectionID if necessary
+ if (iConnectionIdSet)
+ {
+
+ TObexInternalHeader connectionID;
+ connectionID.Set(TObexInternalHeader::EConnectionID, iConnectionID);
+
+ if(!iTransportController->SendPacket().InsertData(connectionID))
+ {
+ LEAVEIFERRORL(KErrOverflow);
+ }
+ }
+ SendRequestPacket();
+ }
+ break;
+ case EOpPut:
+ case EOpGet:
+ // The Put and Get "request" state machines are identical
+ // and live inside the object streamer.
+ {
+ //
+ // For 'Get' the params are what to 'Get' and where to put it
+ // For 'Put' the params are what to put
+ // Either way we need to send a request based on the params
+ iCurrentObject = static_cast<CObexBaseObject*>(aParam);
+
+ // Initialise the object ready for sending
+ TInt err = iCurrentObject->InitSend(TObexOpcode(aOp));
+ if (err != KErrNone)
+ {
+ SET_LAST_ERROR(ECannotInitialiseObject);
+ LEAVEIFERRORL(err);
+ }
+
+ //if a ConnectionID was added then it's important to add the Connection ID
+ //header here, allow it to be processed by PrepareNextSendPacket
+ if ( iConnectionIdSet )
+ {
+ FLOG(_L("\tiConnectionIdSet is true"));
+ TRAPD(err, iCurrentObject->SetConnectionIdL(iConnectionID));
+ if (err != KErrNone)
+ {
+ SET_LAST_ERROR(ECannotSetConnectionId);
+ LEAVEIFERRORL(err);
+ }
+ }
+
+ // If we can...
+ if(iCurrentObject->PrepareNextSendPacket(iTransportController->SendPacket()) != CObexBaseObject::EError)
+ {
+ iTransportController->SendPacket().AddPacketProcessEvents(EObexFinalPacketStarted | EObexFinalPacketFinished);
+
+ // ...send the first request packet
+ FLOG(_L("\tsending first request packet..."));
+ SendRequestPacket();
+ }
+ else
+ {
+ FLOG(_L("\tleaving..."));
+ SET_LAST_ERROR(ECannotPreparePacket);
+ LEAVEIFERRORL(KErrGeneral);
+ }
+ }
+ break;
+
+ case EOpSetPath:
+ {// Build up a setinfo packet and send it.
+ TSetPathInfo* info = static_cast<TSetPathInfo*>(aParam);
+
+ iTransportController->SendPacket().Init(TUint8(aOp));
+ iTransportController->SendPacket().SetFinal();
+
+ TObexSetPathData data;
+ data.iFlags = info->iFlags;
+ data.iConstants = info->iConstants;
+ if(!iTransportController->SendPacket().InsertData(data))
+ {
+ LEAVEIFERRORL(KErrOverflow);
+ }
+
+ //insert the ConnectionID if necessary
+ if ( iConnectionIdSet )
+ {
+
+ TObexInternalHeader connectionID;
+ connectionID.Set(TObexInternalHeader::EConnectionID, iConnectionID);
+
+ if(!iTransportController->SendPacket().InsertData(connectionID))
+ {
+ LEAVEIFERRORL(KErrOverflow);
+ }
+ }
+ if(info->iNamePresent)
+ {
+ TObexInternalHeader name;
+ name.Set(TObexInternalHeader::EName, info->iName);
+ if(!iTransportController->SendPacket().InsertData(name))
+ {
+ LEAVEIFERRORL(KErrOverflow);
+ }
+ }
+ SendRequestPacket();
+ break;
+ }
+ default:
+ IrOBEXUtil::Fault(EClientCommandOpUnrecognised);
+ }
+
+ }
+
+void CObexClient::OnPacketReceive(CObexPacket& aPacket)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ //Cancel the timer
+ if (iPacketTimer->IsActive())
+ {
+ iPacketTimer->Cancel();
+ }
+
+ // Store the response code including the 'final bit'.
+ iLastReceivedResponseOpcode = static_cast<TObexResponse>(aPacket.Opcode() | (aPacket.IsFinal() ? KObexPacketFinalBit : 0));
+
+ if(iTransportController->IsWriteActive())
+ {
+ FLOG(_L("OnPacketReceive received request whilst writing... dropping connection\r\n"));
+ SET_LAST_ERROR(EResponseWhileWriting);
+ CompleteRequest(KErrNone);
+ ControlledTransportDown();
+ return;
+ }
+
+ // Initialise the send packet to ensure that we do not
+ // accidentally send the same packet as last time!
+ iTransportController->SendPacket().Init(0);
+
+ switch(iCurrentOperation)
+ {
+ case EOpConnect:
+ {
+ FLOG(_L("CObexClient::OnPacketReceive Connect OpCode\r\n"));
+ if(ParseConnectPacket(aPacket) == KErrNone)
+ {
+ FLOG(_L("OnPacketReceive Connect Packet parsed \r\n"));
+
+ //the request is only completed if now connected
+ if(GetConnectState() == EConnObex)
+ {
+ SET_LAST_ERROR(ENoError);
+ CompleteRequest(KErrNone);
+ }
+ else //otherwise still some outstanding issues
+ {
+ iTransportController->SendPacket().Init(EOpConnect);
+ TInt err = PrepareConnectPacket(iTransportController->SendPacket());
+ if( err == KErrNone )
+ {
+ FLOG(_L("OnPacketReceive PrepareConnectPacket SUCCESS\r\n"));
+
+ iTransportController->SendPacket().SetFinal();
+ SendRequestPacket();
+ }
+ else if ( GetConnectState() != EWaitForUserInput )
+ {
+ FLOG(_L("OnPacketReceive PrepareConnectPacket FAILED\r\n"));
+ // Last underlying error already set in PrepareConnectPacket().
+ Error(err);
+ }
+ }
+ }
+ else
+ {
+ FLOG(_L("OnPacketReceive Connect Packet Parse FAILED\r\n"));
+ // Last underlying error already set in ParseConnectPacket().
+ Error(KErrAbort);
+ }
+ }
+ break;
+ case EOpDisconnect:
+ {
+ FLOG(_L("CObexClient::OnPacketReceive DisConnect OpCode\r\n"));
+ switch (aPacket.Opcode())
+ {
+ case ERespSuccess:
+ {
+ SET_LAST_ERROR(ENoError);
+ CompleteRequest(KErrNone);
+ }
+ break;
+ case ERespServiceUnavailable:
+ {
+ SET_LAST_ERROR(EBadConnectionId);
+ CompleteRequest(KErrDisconnected);
+ }
+ break;
+ default:
+ {
+ SET_LAST_ERROR(EErrorResponseFromServer);
+ CompleteRequest(KErrDisconnected);
+ }
+ }
+
+ ControlledTransportDown(); // Bring down the transport anyway, otherwise we could end up in a situation where we can't
+ }
+ break;
+ case EOpPut:
+ {
+ FLOG(_L("CObexClient::OnPacketReceive Put OpCode\r\n"));
+ if(!aPacket.IsFinal())
+ {// Multipacket responses not allowed.
+ SET_LAST_ERROR(EMultipacketResponse);
+ Error(KErrCommsOverrun);
+ break;
+ }
+ if(aPacket.Opcode() != ERespContinue
+ && aPacket.Opcode() != ERespSuccess
+ && aPacket.Opcode() != ERespPartialContent)
+ {// Server has returned an OBEX error response. Deal with it...
+ TInt err = IrOBEXUtil::EpocError(aPacket.Opcode());
+ LOG1(_L8("Put error: %d"), err);
+ SET_LAST_ERROR(EErrorResponseFromServer);
+ CompleteRequest(err);
+ break;
+ }
+
+ {
+ CObexBaseObject::TProgress progress =
+ iCurrentObject->PrepareNextSendPacket(iTransportController->SendPacket());
+ iTransportController->SendPacket().AddPacketProcessEvents(EObexFinalPacketStarted | EObexFinalPacketFinished);
+
+ // Work around for a problem both with some DoCoMo phones and Windows 2000:
+ // Their server sends "Success" when it should actually send "Continue",
+ // so we accept either here.
+ if (((progress == CObexBaseObject::EContinue || progress == CObexBaseObject::ELastPacket)
+ && (aPacket.Opcode () == ERespContinue || aPacket.Opcode () == ERespSuccess))||
+ (progress == CObexBaseObject::EComplete
+ && (aPacket.Opcode() == ERespContinue )))
+ {// More stuff to send.
+ SendRequestPacket();
+ }
+ else if(progress == CObexBaseObject::EComplete
+ && (aPacket.Opcode() == ERespSuccess || aPacket.Opcode() == ERespPartialContent ))
+ {// We've completed okay.
+ // There may be headers to extract from this final put response
+ TObexInternalHeader header;
+
+ while(aPacket.ExtractData(header))
+ {
+ FLOG(_L("OnPacketReceive Extracting header from final Put Response"));
+ TInt err=IrOBEXHeaderUtil::ParseHeader(header, *iHeaderSet);
+ if(err != KErrNone)
+ {
+ SET_LAST_ERROR(ECannotExtractFinalPutHeader);
+ Error(err);
+ }
+ }
+ TInt err = IrOBEXUtil::EpocError(aPacket.Opcode());
+ if (err == KErrNone)
+ {
+ SET_LAST_ERROR(ENoError);
+ }
+ else
+ {
+ SET_LAST_ERROR(EErrorResponseFromServer);
+ }
+ CompleteRequest(err);
+ }
+ else
+ {// We're out of sync with server. Give up.
+ SET_LAST_ERROR(EPutOutOfSync);
+ Error(KErrGeneral);
+ }
+ }
+ break;
+ }
+ case EOpGet:
+ {
+ FLOG(_L("CObexClient::OnPacketReceive Get OpCode\r\n"));
+ if(!aPacket.IsFinal())
+ {
+ SET_LAST_ERROR(EMultipacketResponse);
+ Error(KErrCommsOverrun); //??? WTF? Comms overrun?
+ break;
+ }
+
+ // There's only two valid responses to a 'Get' Request...
+ TUint8 respCode = aPacket.Opcode();
+ if( respCode != ERespContinue &&
+ respCode != ERespSuccess )
+ // ... and if we didn't get one of them...
+ {
+ // ...there's not much else we can do
+ SET_LAST_ERROR(EErrorResponseFromServer);
+ CompleteRequest(IrOBEXUtil::EpocError(respCode));
+ break;
+ }
+
+ // Now we know the response was probably valid, see if we need
+ // to send another request packet
+ CObexBaseObject::TProgress progress;
+ progress = iCurrentObject->PrepareNextSendPacket(iTransportController->SendPacket());
+
+ if( progress != CObexBaseObject::EComplete &&
+ progress != CObexBaseObject::ELastPacket)
+ // We're not done sending the request yet.
+ {
+ // So we'd better not have got a 'Success' from the remote end
+ if( progress == CObexBaseObject::EContinue &&
+ respCode == ERespContinue)
+ {
+ iTransportController->SendPacket().AddPacketProcessEvents(EObexFinalPacketStarted | EObexFinalPacketFinished);
+
+ // Not finished sending the request yet, so send the next packet
+ SendRequestPacket();
+ }
+ else
+ {
+ // Something went wrong - can't continue.
+ SET_LAST_ERROR(EGetPrematureSuccess);
+ CompleteRequest(KErrGeneral);
+ }
+
+ // We're done with this packet
+ break;
+ }
+
+ // Still here? We MUST have got an EComplete from the sending state
+ // machine. That means that the response we're handling RIGHT NOW is
+ // the first packet of the thing we are 'Get'ting.
+
+ // Must initialise the object to receive the data from the server
+ iCurrentObject->InitReceive();
+ // Change state so we handle the next response properly
+ iCurrentOperation = EOpGetResponse;
+ }
+ // ** NB ** NO BREAK - DROP THROUGH TO HANDLE THE RESPONSE
+ case EOpGetResponse:
+ // Expecting a possibly multi-packet 'Get' response
+ {
+ FLOG(_L("CObexClient::OnPacketReceive GetResponse OpCode"));
+
+ if(iCurrentObject->ParseNextReceivePacket(aPacket) == CObexBaseObject::EError)
+ {
+ SET_LAST_ERROR(EGetResponseParseError);
+ Error(KErrGeneral);
+ break;
+ }
+ if(aPacket.Opcode() == ERespContinue)
+ {
+ // Send a blank 'Get' request to solicit the next bit of the response
+ SendRequestPacket(EOpGet);
+ FTRACE(iTransportController->SendPacket().Dump());
+ }
+ else
+ {
+ // Got all of the response, give it to the user
+ if (aPacket.Opcode() == ERespSuccess)
+ {
+ SET_LAST_ERROR(ENoError);
+ }
+ else
+ {
+ SET_LAST_ERROR(EErrorResponseFromServer);
+ }
+ CompleteRequest(IrOBEXUtil::EpocError(aPacket.Opcode()));
+ }
+ }
+ break;
+ case EOpSetPath:
+ FLOG(_L("CObexClient::OnPacketReceive Set Path OpCode\r\n"));
+ if (aPacket.Opcode() == ERespSuccess)
+ {
+ SET_LAST_ERROR(ENoError);
+ }
+ else
+ {
+ SET_LAST_ERROR(EErrorResponseFromServer);
+ }
+ CompleteRequest(IrOBEXUtil::EpocError(aPacket.Opcode()));
+ break;
+ case EOpAbortNoFBit:
+ FLOG(_L("CObexClient::OnPacketReceive Abort NoFBit OpCode\r\n"));
+ SendRequestPacket(EOpAbort);
+ iCurrentOperation = EOpAbort;
+ break;
+ case EOpAbort:
+ {
+ FLOG(_L("CObexClient::OnPacketReceive Abort OpCode\r\n"));
+
+ SET_LAST_ERROR(EAborted);
+ if(aPacket.IsFinal() && aPacket.Opcode() == ERespSuccess)
+ {// Just complete the put/get with code aborted
+ CompleteRequest(KErrAbort);
+ }
+ else
+ {// Report an error while aborting -> causes a disconnect
+ Error(KErrAbort);
+ }
+ }
+ break;
+ default:
+// FPrint(_L("CObexClient::OnPacketReceive unknown opcode 0x%X!"),
+// iCurrentOperation);
+ break;
+ }
+
+ // Client has finished with the read packet so queue the next read (if necessary)
+ if(iConnectState >= EConnTransport)
+ {
+ iTransportController->Receive();
+ }
+
+ }
+
+TInt CObexClient::ParseConnectPacket(CObexPacket& aPacket)
+ {
+ TInt retValue = KErrNone;
+ TConnectState nextState = EDropLink;
+
+ if(!iTransportController || !iTransportController->ExtractRemoteConnectInfo(aPacket, iRemoteInfo.iVersion, iRemoteInfo.iFlags))
+ {
+ FLOG(_L("CObexClient::ParseConnectPacket Extract Remote Info FAILED\r\n"));
+ SET_LAST_ERROR(ECannotExtractConnectInfo);
+ return KErrGeneral;
+ }
+ FLOG(_L("CObexClient::ParseConnectPacket Extract Remote Info Success\r\n"));
+
+ TObexInternalHeader hdr;
+
+ if ( aPacket.Opcode() == ERespSuccess )
+ {
+ FLOG(_L("ParseConnectPacket ERespSuccess Opcode\r\n"));
+
+ //if a simple connect was originally requested
+ //then a simple ERespSuccess without any headers is enough
+ if ( GetConnectState() == ESimpleConnRequest )
+ nextState = EConnObex;
+ //if responding to a chall from the server
+ if (( GetConnectState() == EWaitForFinalResponse)&&(!iChallenge))
+ nextState = EConnObex;
+ while(aPacket.ExtractData(hdr))
+ {
+ switch(hdr.HI())
+ {
+ case TObexInternalHeader::EWho:
+ {
+ FLOG(_L("ParseConnectPacket Extracting EWHO header\r\n"));
+ iRemoteInfo.iWho.Copy(hdr.HVByteSeq(), hdr.HVSize() > iRemoteInfo.iWho.MaxSize() ? iRemoteInfo.iWho.MaxSize() : hdr.HVSize());
+ }
+ break;
+ case TObexInternalHeader::EConnectionID:
+ {
+ FLOG(_L("ParseConnectPacket Extracting EConnectionID header\r\n"));
+
+ TUint32 newConnectionID = ((hdr.HVByteSeq()[0] << 24) + (hdr.HVByteSeq()[1] << 16) + (hdr.HVByteSeq()[2] << 8) + (hdr.HVByteSeq()[3]));
+ SetConnectionID(newConnectionID);
+
+ if ( GetConnectState() == ESimpleConnRequest )
+ {
+ nextState = EConnObex;
+ }
+ }
+ break;
+ case TObexInternalHeader::EAuthResponse:
+ {
+ if (iChallenge)
+ {
+ FLOG(_L("ParseConnectPacket Extracting EAuthResponse header\r\n"));
+ //extract the response into it's constituent parts
+ TRAPD(err, ProcessChallResponseL(hdr));
+ if ( err == KErrNone )
+ {
+ FLOG(_L("ParseConnectPacket ProcessChallResponse Success\r\n"));
+
+ if ((GetConnectState() == EChallConnRequested) || ( GetConnectState() == EWaitForFinalResponse))
+ {
+ nextState = EConnObex;
+ }
+ else
+ {
+ SET_LAST_ERROR(EUnexpectedChallengeResponse);
+ nextState = EDropLink;
+ retValue = KErrGeneral;
+ }
+ }
+ else
+ {
+ FLOG(_L("ParseConnectPacket ProcessChallResponse FAILED\r\n"));
+ SET_LAST_ERROR(ECannotProcessChallenge);
+ nextState = EDropLink;
+ retValue = KErrGeneral;
+ }
+ }
+ else
+ {
+ // if no challenge was issued, then receiving a challenge response means the peer is badly
+ // behaved. For this case we simply ignore the header, anything else would be too drastic.
+ FLOG(_L("ParseConnectPacket Chall Response received when no Chall issued\r\n"));
+ }
+ }
+ break;
+ default:
+ break;
+ }//end switch
+ }//end while
+ }
+ else if (aPacket.Opcode() == ERespUnauthorized )
+ {
+ FLOG(_L("ParseConnectPacket ERespUnauthorized Opcode\r\n"));
+ // Only valid header here is AuthChallenge, if it's absent then authentication failed.
+ TBool challengeAbsent = ETrue;
+ while(aPacket.ExtractData(hdr))
+ {
+ switch(hdr.HI())
+ {
+ case TObexInternalHeader::EAuthChallenge:
+ {
+ FLOG(_L("ParseConnectPacket Extracting EAuthChallenge header\r\n"));
+ challengeAbsent = EFalse;
+ TRAPD(err, ProcessChallengeL(hdr));
+ if ( !err )
+ {
+ nextState = EConnChallRxed;
+ retValue = KErrNone;
+ }
+ else
+ {
+ SET_LAST_ERROR(ECannotProcessChallenge);
+ retValue = KErrGeneral;
+ }
+#ifdef TEST_CLIENT_CHANGES_ITS_MIND_ABOUT_CHALLENGE
+ //this will force the client to challenge the server
+ //even if it didn't challenge initially
+ //this is not standard behaviour for our client
+ //but the server must be capable of handling this situation
+ iChallenge = ETrue;
+#endif
+ }
+ break;
+ default:
+ break;
+ }//end switch
+ }//end while
+
+ if (challengeAbsent)
+ {
+ SET_LAST_ERROR(EChallengeAbsent);
+ retValue = KErrGeneral;
+ }
+ }
+ else
+ {
+ FLOG(_L("ParseConnectPacket Unknown Opcode Opcode\r\n"));
+ SET_LAST_ERROR(EBadOpcodeInConnectPacket);
+ retValue = KErrGeneral;
+ }
+
+
+ SetConnectState(nextState);
+ return(retValue);
+ }
+
+void CObexClient::OnError(TInt aError)
+ {
+ LOG1(_L8("CObexClient::OnError(%d)"), aError);
+ CompleteRequest(aError);
+
+ // Don't reset the Obex link for a normal disconnection, as
+ // technically there is no real error requiring such drastic
+ // action. In the case of USB, stalling the IN endpoint will
+ // cause another round of alternate interface changes which
+ // appears to confuse either Obex or the USB connector.
+
+ // In other words the error KErrDisconnected occurs as a
+ // result of the transport coming down, so there's no need to
+ // signal a transport error in this case.
+
+ // If this is called during construction, iTransportController could be NULL
+ if(aError!=KErrDisconnected && iTransportController)
+ {
+ iTransportController->SignalTransportError();
+ }
+ }
+
+
+
+TInt CObexClient::PrepareConnectPacket(CObexPacket& aPacket)
+ {
+ TInt retValue = KErrNone;
+ TConnectState nextState = EDropLink;
+
+ if (!iTransportController->InsertLocalConnectInfo(aPacket, iLocalInfo.iVersion, iLocalInfo.iFlags))
+ {
+ FLOG(_L("CObexClient::PrepareConnectPacket local data insertion FAILED\r\n"));
+ SET_LAST_ERROR(ECannotInsertConnectInfo);
+ return(KErrGeneral);
+ }
+ FLOG(_L("CObexClient::PrepareConnectPacket local data inserted Succesfully\r\n"));
+
+ //iCurrentObject could be NULL if Connect with no headers was requested
+ if ( iCurrentObject )
+ iCurrentObject->PrepareConnectionHeader(iTransportController->SendPacket());
+
+
+ if (( iChallenge )&&(!retValue)) //if a challenge is to be sent
+ {
+ FLOG(_L("PrepareConnectPacket Generating challenge\r\n"));
+
+ retValue = GenerateChallenge(aPacket);
+ if ( retValue == KErrNone)
+ {
+ nextState = EChallConnRequested;
+ }
+ else
+ {
+ nextState = EDropLink;
+ }
+ }
+
+
+ //check the state of the connect instruction
+ if ( GetConnectState() == EConnTransport ) //first time round the loop
+ {
+ //it's going to be a simple challenge unless
+ //it's already been decides it's a EChallConnRequested
+ if ( nextState == EDropLink )
+ nextState = ESimpleConnRequest;
+ }
+ else if (GetConnectState() == EConnChallRxed)
+ {
+ if (iCallBack )
+ {
+ FLOG(_L("PrepareConnectPacket requesting password from user\r\n"));
+
+ //ask the user for a password
+ //the callback does happens in the method OnPacketReceive()
+ nextState = EWaitForUserInput;
+ retValue = KErrGeneral; //mustn't send yet wait for reply from user
+ }
+ else
+ {
+ FLOG(_L("PrepareConnectPacket chall rxed but can't ask for password dropping link\r\n"));
+ SET_LAST_ERROR(EChallengeRejected);
+ retValue = KErrIrObexConnectChallRejected;
+ nextState = EDropLink;
+ }
+ } //or drop the link
+ else
+ {
+ FLOG(_L("PrepareConnectPacket unknown connect state\r\n"));
+ SET_LAST_ERROR(EPrepareConnectPacketIncorrectState);
+ retValue = KErrGeneral;
+ nextState = EDropLink;
+ }
+ SetConnectState(nextState);
+
+ return(retValue);
+ }
+
+void CObexClient::OnTransportUp()
+ {
+ FLOG(_L("CObexClient::OnTransportUp\r\n"));
+ ResetConnectionID();
+
+ iTransportController->SendPacket().Init(EOpConnect);
+ if (PrepareConnectPacket(iTransportController->SendPacket()) == KErrNone)
+ {
+ FLOG(_L("OnTransportUp PrepareConnectPacket Succesfull\r\n"));
+
+ iTransportController->SendPacket().SetFinal();
+ FTRACE(iTransportController->SendPacket().Dump());
+ SendRequestPacket();
+ }
+ }
+
+void CObexClient::OnTransportDown()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // Cancel the timer
+ if (iPacketTimer->IsActive())
+ {
+ iPacketTimer->Cancel();
+ }
+ // If there's an outstanding request, an error has occured
+ // But don't do anything if an error has already been set (due to e.g. packet timer timeout)
+ if(iPendingRequest && !iIsLastErrorSet)
+ {
+ SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+ Error(KErrIrObexClientPutPeerAborted); //extended error for IrObex,("Other IR device aborted the transfer")
+ }
+ }
+
+/** Signals an event has ocurred.
+
+@released
+@internalComponent
+@param aEvent The event that has ocurred (TObexPacketProcessEvent)
+*/
+void CObexClient::SignalPacketProcessEvent(TInt aEvent)
+ {
+ if(aEvent & KObexPacketSignallerInterestingClientEvents)
+ {
+ // Currently all notifications are related to writes, so only need to
+ // clear events from the SendPacket.
+ iTransportController->SendPacket().RemovePacketProcessEvents(aEvent);
+
+ iPacketProcessSignaller->Signal(static_cast<TObexPacketProcessEvent>(aEvent));
+ }
+ }
+
+void CObexClient::SetRequest(TRequestStatus& aStatus, TOperation aOperation)
+ {
+ aStatus = KRequestPending;
+ iPendingRequest = &aStatus;
+ iCurrentOperation = aOperation;
+ }
+
+void CObexClient::CompleteRequest(const TInt aCompletion)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(iPendingRequest)
+ {
+ // Some errors, particularly IR, only come up through OnError().
+ // Thus the setting of underlying error happens here.
+ switch (aCompletion)
+ {
+ case KErrIrObexRespTimedOut:
+ {
+ SET_LAST_ERROR(EResponseTimeout);
+ }
+ break;
+ case KErrDisconnected:
+ {
+ // There are at least two ways of getting here.
+ // The first is disruption to the transport (e.g. IrDA beam blocked)
+ // and the second is attempting an operation other than connect when
+ // there is no connection (see CObexClient::ClientCommandL()).
+ // We don't want to set the last error twice in the second case,
+ // so check that the last error is not set before setting it here.
+ if (!iIsLastErrorSet)
+ {
+ SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+ }
+ }
+ break;
+ case KErrCompletion:
+ {
+ // This is an error from the destructor.
+ // Operation is complete, successfully or otherwise.
+ // Since the operation is still outstanding and the interruption
+ // was initiated locally, the operation is effectively aborted.
+ SET_LAST_ERROR(EAborted);
+ }
+ break;
+ case KErrNotReady:
+ {
+ // This error occurs when the BT link times out.
+ SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+ }
+ break;
+ case KErrCouldNotConnect:
+ {
+ // BT could not connect.
+ SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+ }
+ break;
+ case KErrGeneral:
+ {
+ // Since Obex also uses this error elsewhere, only set a last error
+ // if none has been set previously.
+ if (!iIsLastErrorSet)
+ {
+ SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+ }
+ }
+ break;
+ default:
+ {
+ // If an error has not yet been set, then set the last error as appropriate.
+ if (!iIsLastErrorSet)
+ {
+ // For all other errors.
+ SET_LAST_ERROR(EOpOutstandingOnTransportDown);
+ }
+ }
+ }
+ CHECK_LAST_ERROR_IS_SET;
+ User::RequestComplete(iPendingRequest, aCompletion);// Sets iPendingRequest = NULL
+ }
+ iPendingRequest=NULL;
+ iCurrentOperation = EOpIdle;
+
+ if (iPacketTimer)
+ {
+ iPacketTimer->Cancel();
+ }
+ }
+
+void CObexClient::EmptyHeaderSet()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHeaderSet->First();
+ while(iHeaderSet->This(iHeader) == KErrNone)
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+ }
+
+void CObexClient::TimeOutCompletion()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ CompleteRequest(KErrIrObexRespTimedOut);
+ // Disconnect transport to prevent the client entering an invalid state
+ ForcedTransportDown();
+ }
+
+void CObexClient::SendRequestPacket()
+ {
+ //Send the request.
+ iTransportController->Send();
+
+ //Set the Timer.
+ iPacketTimer->SetTimer(iCmdTimeOutDuration);
+ }
+
+void CObexClient::SendRequestPacket(TObexOpcode aObexOpcode)
+ {
+ //Send the request.
+ iTransportController->Send(aObexOpcode);
+
+ //Set the Timer.
+ iPacketTimer->SetTimer(iCmdTimeOutDuration);
+ }
+
+/**
+Provides additional interfaces for CObexClient.
+
+@param aUid The UID of the interface that is required.
+@return A pointer to an instance implementing the interface represented by aUid.
+*/
+EXPORT_C TAny* CObexClient::ExtensionInterface(TUid aUid)
+ {
+ TAny* ret = NULL;
+
+ if (aUid == KObexClientErrorResolverInterface)
+ {
+ ret = static_cast<MObexClientErrorResolver*>(iErrorEngine);
+ }
+
+ return ret;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexconstants.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,175 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexconstants.h>
+#include "obexconstantsinternal.h"
+#include <obex/internal/obexinternalconstants.h>
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+@file
+@internalComponent
+*/
+
+/**
+Sets up class with default values
+@publishedAll
+@released
+*/
+EXPORT_C TObexProtocolPolicy::TObexProtocolPolicy ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // Default set-up for version 0
+ // This is set for backwards compatibility, so change with caution!
+ iVersion = 0;
+ iReceiveMtu = KObexPacketDefaultSize;
+ iTransmitMtu = KObexPacketDefaultSize;
+ }
+
+/**
+Sets the maximum size of the receive packet buffer for the policy.
+For the IrDA transport, if the new receive buffer size is different to
+KObexPacketDefaultSize the receive packet size is set to equal the new
+buffer size. Otherwise the packet size is set to the protocol defined limit.
+@param aReceiveMtu The new buffer size
+@return KErrNone on success. KErrArgument if the packet size is not supported
+@publishedAll
+@released
+*/
+EXPORT_C TInt TObexProtocolPolicy::SetReceiveMtu ( TUint16 aReceiveMtu )
+ {
+ LOG_LINE
+ LOG_FUNC
+ LOG1(_L8("\taReceiveMtu = %d"), aReceiveMtu);
+
+ // Can't set size greater than the maximum, so only check if it's too small
+ if ( aReceiveMtu >= KObexPacketMinSize )
+ iReceiveMtu = aReceiveMtu;
+
+ TInt ret = ( iReceiveMtu == aReceiveMtu ) ? KErrNone : KErrArgument;
+ LOG1(_L8("\tret = %d"), ret);
+ return ret;
+ }
+
+/**
+Sets the maximum size of the transmit packet buffer for the policy
+@param aTransmitMtu The new buffer size
+@return KErrNone on success. KErrArgument if the packet size is not supported
+@publishedAll
+@released
+*/
+EXPORT_C TInt TObexProtocolPolicy::SetTransmitMtu ( TUint16 aTransmitMtu )
+ {
+ LOG_LINE
+ LOG_FUNC
+ LOG1(_L8("\taTransmitMtu = %d"), aTransmitMtu);
+
+ // Can't set size greater than the maximum, so only check if it's too small
+ if ( aTransmitMtu >= KObexPacketMinSize )
+ iTransmitMtu = aTransmitMtu;
+
+ TInt ret = ( iTransmitMtu == aTransmitMtu ) ? KErrNone : KErrArgument;
+ LOG1(_L8("\tret = %d"), ret);
+ return ret;
+ }
+
+/**
+Gets the version of the protocol policy format that this class supports
+@return Protocol policy version
+@publishedAll
+@released
+*/
+EXPORT_C TUint16 TObexProtocolPolicy::Version () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ LOG1(_L8("\tiVersion = %d"), iVersion);
+ return iVersion;
+ }
+
+/**
+Gets the policy's receive packet buffer size
+@return Receive packet buffer size
+@publishedAll
+@released
+*/
+EXPORT_C TUint16 TObexProtocolPolicy::ReceiveMtu () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ LOG1(_L8("\tiReceiveMtu = %d"), iReceiveMtu);
+ return iReceiveMtu;
+ }
+
+/**
+Gets the policy's transmit packet buffer size
+@return Transmit packet buffer size
+@publishedAll
+@released
+*/
+EXPORT_C TUint16 TObexProtocolPolicy::TransmitMtu () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ LOG1(_L8("\tiTransmitMtu = %d"), iTransmitMtu);
+ return iTransmitMtu;
+ }
+
+// TObexConnectInfo
+/**
+@publishedAll
+@released
+*/
+EXPORT_C TObexConnectInfo::TObexConnectInfo()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iVersion = KObexVersion;
+ iFlags = 0;
+ }
+
+/**
+@publishedAll
+@released
+*/
+EXPORT_C TUint8 TObexConnectInfo::VersionMajor() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return(STATIC_CAST(TUint8,(iVersion & 0xF0) >> 4));
+ }
+
+/**
+@publishedAll
+@released
+*/
+EXPORT_C TUint8 TObexConnectInfo::VersionMinor() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return(STATIC_CAST(TUint8,(iVersion & 0x0F)));
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexerrorengine.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,117 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "obexerrorengine.h"
+#include "OBEXUTIL.H"
+
+CObexErrorEngine* CObexErrorEngine::NewL()
+ {
+ CObexErrorEngine* self = new (ELeave) CObexErrorEngine;
+ return self;
+ }
+
+CObexErrorEngine::CObexErrorEngine()
+ {
+ iLastError = ENoError;
+ }
+
+/**
+Function used to retreive an extended error code for the last completed client operation.
+
+@param aErrorSet The set of errors that the resolved error will lie within.
+@return An extended error code that lies within the error set specified.
+*/
+TUint CObexErrorEngine::LastError(TObexClientErrorResolutionSetType aErrorSet) const
+ {
+ TUint ret = 0;
+
+ if (aErrorSet == EObexClientBasicErrorResolutionSet)
+ {
+ switch (iLastError)
+ {
+ case ENoError:
+ {
+ ret = EObexRequestAccepted;
+ }
+ break;
+
+ case EAlreadyConnected:
+ case EChallengeRejected:
+ case EChallengeAbsent:
+ case EBadConnectionId:
+ case EErrorResponseFromServer:
+ {
+ ret = EObexRequestNotAccepted;
+ }
+ break;
+
+ case EResponseTimeout:
+ {
+ ret = EObexRequestTimeout;
+ }
+ break;
+
+ case ECannotInsertConnectInfo:
+ case EPrepareConnectPacketIncorrectState:
+ case EResponseWhileWriting:
+ case ECannotExtractConnectInfo:
+ case ECannotProcessChallenge:
+ case EUnexpectedChallengeResponse:
+ case EBadOpcodeInConnectPacket:
+ case EAborted:
+ case ECannotInitialiseObject:
+ case ECannotSetConnectionId:
+ case ECannotPreparePacket:
+ case EMultipacketResponse:
+ case ECannotExtractFinalPutHeader:
+ case EPutOutOfSync:
+ case EGetPrematureSuccess:
+ case EGetResponseParseError:
+ {
+ ret = EObexRequestLocalInterruption;
+ }
+ break;
+
+ case ETransportUpFailed:
+ case EOpOutstandingOnTransportDown:
+ case EDisconnected:
+ {
+ ret = EObexRequestLinkInterruption;
+ }
+ break;
+
+ default:
+ {
+ IrOBEXUtil::Fault(EUnderlyingErrorUnrecognised);
+ }
+ }
+ }
+ else
+ {
+ IrOBEXUtil::Fault(EErrorSetUnrecognised);
+ }
+
+ return ret;
+ }
+
+void CObexErrorEngine::SetLastError(TObexClientUnderlyingError aError)
+ {
+ iLastError = aError;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexfilewriter.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,31 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "obexfilewriter.h"
+
+/**
+Destructor
+*/
+MObexFileWriter::~MObexFileWriter()
+ {
+ }
+
+//
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexheader.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,678 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <obexheaders.h>
+#include <obexconstants.h>
+#include "obexunderlyingheader.h"
+#include "OBEXUTIL.H"
+#include "logger.h"
+
+#define BAD_HEADER_ACTION IrOBEXUtil::Panic(EHeaderAsBadType)
+
+#if ( defined __FLOG_ACTIVE && defined __LOG_FUNCTIONS__ )
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+Standard constructor
+
+@internalComponent
+ */
+CRefCounted::CRefCounted()
+ {
+ iCount = 0;
+ }
+
+/**
+Increments the object's reference count.
+
+@internalComponent
+*/
+void CRefCounted::Open() const
+ {
+ iCount++;
+ }
+
+/**
+Decrements the object's reference count and deletes the object when count goes to zero.
+
+@internalComponent
+*/
+void CRefCounted::Close() const
+ {
+ iCount--;
+ if (iCount == 0)
+ {
+ delete this;
+ }
+ }
+
+/**
+@panic ObexFault ERefCountNonZero Panics if there are still references to this object or if the reference count is negative.
+
+@internalComponent
+*/
+CRefCounted::~CRefCounted()
+ {
+ __ASSERT_ALWAYS(iCount == 0, IrOBEXUtil::Fault(ERefCountNonZero));
+ }
+
+EXPORT_C CObexHeader* CObexHeader::NewL()
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexHeader* self = new(ELeave) CObexHeader();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+Return a pointer to a copy of this object. This must be used instead
+of merely copying the pointer to the initial CObexHeader object as
+reference counting is used to keep track of instances of the header.
+The underlying data is not cloned, so any change to the data pointed to
+by this pointer could change the underlying data.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexHeader* CObexHeader::CopyL() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ CObexHeader* copy = new(ELeave) CObexHeader(iHeader);
+ copy->iHeader->Open();
+ return copy;
+ }
+
+/**
+@internalComponent
+Standard constructor.
+
+@see CObexHeaderSet
+*/
+CObexHeader::CObexHeader()
+ {
+ }
+
+/**
+Standard constructor, taking a pointer to an underlying object.
+
+@internalComponent
+*/
+CObexHeader::CObexHeader(CObexUnderlyingHeader* aHeader)
+ : iHeader(aHeader)
+ {
+ }
+
+/**
+Sets this object to use the same underlying header as the parameter.
+This performs essentially the same function as the CopyL() function,
+but does not allocate a new object.
+The underlying data is not cloned, so any change to the data pointed to
+by this pointer could change the underlying data.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::Set(CObexHeader* aHeader)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ Reset();
+ iHeader = aHeader->iHeader;
+ iHeader->Open();
+ }
+
+/**
+Resets the contents of this header, discarding the underlying data.
+This is only called by the last instance of the header.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::Reset()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHeader->Close();
+ iHeader = 0;
+ }
+
+/**
+Phase two constructor.
+Create the underlying header object. This is reference counted
+so ownership passes to itself.
+
+@internalComponent
+*/
+void CObexHeader::ConstructL()
+ {
+ iHeader = CObexUnderlyingHeader::NewL();
+ iHeader->Open();
+ }
+
+/**
+Standard destructor.
+
+@publishedAll
+@released
+*/
+CObexHeader::~CObexHeader()
+ {
+ if (iHeader != 0)
+ {
+ iHeader->Close();
+ }
+ }
+
+/**
+Resets and destroys all header attributes.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::ResetContents()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHeader->ResetContents();
+ }
+
+/**
+Sets the attibutes of this header.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetAttributes(TUint16 aAttr)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHeader->SetAttributes(aAttr);
+ }
+
+/**
+Return the attibute set currently in force.
+
+@publishedAll
+@released
+*/
+EXPORT_C TUint16 CObexHeader::Attributes() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iHeader->Attributes();
+ }
+
+/**
+Return the type of this header.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexHeader::THeaderType CObexHeader::Type() const
+
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iHeader->Type();
+ }
+
+/**
+Returns the header identifier.
+
+@publishedAll
+@released
+*/
+EXPORT_C TUint8 CObexHeader::HI() const
+ {
+ // Don't log this function as it's too verbose.
+ //LOG_LINE
+ //LOG_FUNC
+
+ return iHeader->HI();
+ }
+
+/**
+Returns this header as a byte value.
+@return The value of this header.
+@panic Obex EHeaderAsBadType Panics builds if header is of incorrect type.
+
+@publishedAll
+@released
+*/
+EXPORT_C TUint8 CObexHeader::AsByte() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iHeader->AsByte();
+ }
+
+/**
+Returns this header as a four-byte value.
+@return The value of this header.
+@panic Obex EHeaderAsBadType Panics if header is of incorrect type.
+
+@publishedAll
+@released
+*/
+EXPORT_C TUint32 CObexHeader::AsFourByte() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iHeader->AsFourByte();
+ }
+
+/**
+Returns this header as a byte sequence.
+@return The value of this header.
+@panic Obex EHeaderAsBadType Panics if header is of incorrect type.
+
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC8& CObexHeader::AsByteSeq() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iHeader->AsByteSeq();
+ }
+
+/**
+Returns this header as an Unicode string.
+@return The value of this header.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC16& CObexHeader::AsUnicode() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iHeader->AsUnicode();
+ }
+
+/**
+Sets this header to represent a byte value.
+Forces header type to be a byte (which may therefore change the HI
+value).
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetByte(const TUint8 aHI, const TUint8 aByte)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHeader->SetByte(aHI, aByte);
+ }
+
+/**
+Sets this header to represent a four-byte value.
+Forces header type to be a four-byte (which may therefore change
+the HI value).
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetFourByte(const TUint8 aHI, const TUint32 aFourByte)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHeader->SetFourByte(aHI, aFourByte);
+ }
+
+/**
+Sets this header to represent a byte sequence.
+Forces header type to be a byte sequence (which may therefore change
+the HI value).
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHeader->SetByteSeqL(aHI, aByteSeq);
+ }
+
+/**
+Forces header type to be a byte (which may therefore change the HI
+value).
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeader::SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHeader->SetUnicodeL(aHI, aUnicode);
+ }
+
+/**
+@return The encoded size of this header in bytes, including the
+HI byte and the HV body.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexHeader::EncodedSize() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iHeader->EncodedSize();
+ }
+
+// ----------------------------------------------------------------------
+// Now the real code. CObexHeader is just a facade, passing requests on
+// to an underlying reference counted object. This is where the real
+// work goes on.
+// ----------------------------------------------------------------------
+
+/**
+@internalComponent
+NewL method
+*/
+CObexUnderlyingHeader* CObexUnderlyingHeader::NewL()
+ {
+ CObexUnderlyingHeader* self = new(ELeave) CObexUnderlyingHeader();
+ return self;
+ }
+
+/**
+@internalComponent
+Standard constructor.
+*/
+CObexUnderlyingHeader::CObexUnderlyingHeader()
+ {
+ }
+
+/**
+@internalComponent
+Standard destructor.
+*/
+CObexUnderlyingHeader::~CObexUnderlyingHeader()
+ {
+ ResetContents();
+ }
+
+/**
+@internalComponent
+Resets and destroys all header attributes.
+*/
+void CObexUnderlyingHeader::ResetContents()
+ {
+ // If a byte sequence or Unicode string header, destroy
+ // the underlying HBufC.
+ switch (Type())
+ {
+ case CObexHeader::EByteSeq:
+ delete iHV.iByteSeq;
+ break;
+
+ case CObexHeader::EUnicode:
+ delete iHV.iUnicode;
+ break;
+
+ default:
+ // Not a pointer, nothing required
+ {}
+ }
+
+ iAttributes = 0;
+ iHI = 0;
+ // Resetting the fourbyte data, will explicitly reset all the data
+ // stored in the union (so no need to reset unicode, byte, byteseq)
+ iHV.iFourByte = 0;
+ }
+
+/**
+@internalComponent
+Sets the attibutes of this header.
+*/
+void CObexUnderlyingHeader::SetAttributes(TUint16 aAttr)
+ {
+ iAttributes = aAttr;
+ }
+
+/**
+@internalComponent
+Return the attibute set currently in force.
+*/
+TUint16 CObexUnderlyingHeader::Attributes() const
+ {
+ return iAttributes;
+ }
+
+/**
+@internalComponent
+Return the type of this header.
+*/
+CObexHeader::THeaderType CObexUnderlyingHeader::Type() const
+ {
+ // Call the internal inline. Just in case the header representation
+ // changes!
+ return static_cast<CObexHeader::THeaderType>(ObexHeaderType(iHI));
+ }
+
+/**
+@internalComponent
+Returns the header identifier.
+*/
+TUint8 CObexUnderlyingHeader::HI() const
+ {
+ return iHI;
+ }
+
+/**
+@internalComponent
+Returns this header as a byte value.
+@return The value of this header.
+@leave KErrNotSupported (release builds only) if this header is of
+incorrect type.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+*/
+TUint8 CObexUnderlyingHeader::AsByte() const
+ {
+ __ASSERT_ALWAYS((ObexHeaderType(iHI) == CObexHeader::EByte), BAD_HEADER_ACTION);
+
+ return iHV.iByte;
+ }
+
+/**
+@internalComponent
+Returns this header as a four-byte value.
+@return The value of this header.
+@leave KErrNotSupported (release builds only) if this header is of
+incorrect type.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+*/
+TUint32 CObexUnderlyingHeader::AsFourByte() const
+ {
+ __ASSERT_ALWAYS((ObexHeaderType(iHI) == CObexHeader::EFourByte), BAD_HEADER_ACTION);
+
+ return iHV.iFourByte;
+ }
+
+/**
+@internalComponent
+Returns this header as a byte sequence.
+@return The value of this header.
+@leave KErrNotSupported (release builds only) if this header is of
+incorrect type.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+*/
+const TDesC8& CObexUnderlyingHeader::AsByteSeq() const
+ {
+ __ASSERT_ALWAYS((ObexHeaderType(iHI) == CObexHeader::EByteSeq), BAD_HEADER_ACTION);
+
+ if (iHV.iByteSeq)
+ return *(iHV.iByteSeq);
+ else
+ return KNullDesC8();
+ }
+
+/**
+@internalComponent
+Returns this header as an Unicode string.
+@return The value of this header.
+@leave KErrNotSupported (release builds only) if this header is of
+incorrect type.
+@panic Obex EHeaderAsBadType Panics in debug builds if header is of incorrect type.
+*/
+const TDesC16& CObexUnderlyingHeader::AsUnicode() const
+ {
+ __ASSERT_ALWAYS((ObexHeaderType(iHI) == CObexHeader::EUnicode), BAD_HEADER_ACTION);
+
+ if (iHV.iUnicode)
+ return *(iHV.iUnicode);
+ else
+ return KNullDesC16();
+ }
+
+/**
+@internalComponent
+Sets this header to represent a byte value.
+Forces header type to be a byte (which may therefore change the HI
+value).
+*/
+void CObexUnderlyingHeader::SetByte(const TUint8 aHI, const TUint8 aByte)
+ {
+ __ASSERT_ALWAYS((ObexHeaderType(aHI) == CObexHeader::EByte), BAD_HEADER_ACTION);
+
+ if ((iHI & KObexHeaderTypeMask) != (aHI & KObexHeaderTypeMask))
+ ResetContents();
+
+ iHI = aHI;
+ iHV.iByte = aByte;
+ }
+
+/**
+@internalComponent
+Sets this header to represent a four-byte value.
+Forces header type to be a four-byte (which may therefore change
+the HI value).
+*/
+void CObexUnderlyingHeader::SetFourByte(const TUint8 aHI, const TUint32 aFourByte)
+ {
+ __ASSERT_ALWAYS((ObexHeaderType(aHI) == CObexHeader::EFourByte), BAD_HEADER_ACTION);
+
+ if ((iHI & KObexHeaderTypeMask) != (aHI & KObexHeaderTypeMask))
+ ResetContents();
+
+ iHI = aHI;
+ iHV.iFourByte = aFourByte;
+ }
+
+/**
+@internalComponent
+Sets this header to represent a byte sequence.
+Forces header type to be a byte sequence (which may therefore change
+the HI value).
+*/
+void CObexUnderlyingHeader::SetByteSeqL(const TUint8 aHI, const TDesC8& aByteSeq)
+ {
+ __ASSERT_ALWAYS((ObexHeaderType(aHI) == CObexHeader::EByteSeq), BAD_HEADER_ACTION);
+
+ HBufC8* tmp = aByteSeq.AllocL();
+ if ((iHI & KObexHeaderTypeMask) != (aHI & KObexHeaderTypeMask))
+ ResetContents();
+
+ iHI = aHI;
+ delete iHV.iByteSeq;
+ iHV.iByteSeq = tmp;
+ }
+
+/**
+@internalComponent
+Sets this header to represent a byte value.
+Forces header type to be a byte (which may therefore change the HI
+value).
+*/
+void CObexUnderlyingHeader::SetUnicodeL(const TUint8 aHI, const TDesC16& aUnicode)
+ {
+ __ASSERT_ALWAYS((ObexHeaderType(aHI) == CObexHeader::EUnicode), BAD_HEADER_ACTION);
+
+ HBufC16* tmp = aUnicode.AllocL();
+ if ((iHI & KObexHeaderTypeMask) != (aHI & KObexHeaderTypeMask))
+ ResetContents();
+
+ iHI = aHI;
+ delete iHV.iUnicode;
+ iHV.iUnicode = tmp;
+ }
+
+TInt CObexUnderlyingHeader::EncodedSize() const
+ {
+ const TInt KHIByteSize=1;
+ const TInt KLengthEncoding=2;
+ const TInt KOneByteHeaderEncodedSize=1+KHIByteSize;
+ const TInt KFourByteHeaderEncodedSize=4+KHIByteSize;
+
+ TInt encodedSize=0;
+
+ switch(Type())
+ {
+
+ case CObexHeader::EUnicode:
+ encodedSize=KHIByteSize+KLengthEncoding+AsUnicode().Size();
+ if(AsUnicode().Size()>0)
+ encodedSize+=2; // Two extra byes for null terminator
+ break;
+
+ case CObexHeader::EByteSeq:
+ encodedSize=KHIByteSize+KLengthEncoding+AsByteSeq().Size();
+ break;
+
+ case CObexHeader::EByte:
+ encodedSize=KOneByteHeaderEncodedSize;
+ break;
+
+ case CObexHeader::EFourByte:
+ encodedSize=KFourByteHeaderEncodedSize;
+ break;
+
+ }
+
+ return encodedSize;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexheaderset.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,467 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <obexheaders.h>
+#include "OBEXUTIL.H"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+Called in response to First() being called on the iterator object.
+The default implementation does nothing---some implementations may
+wish to reset state variables.
+
+@publishedAll
+@released
+*/
+EXPORT_C void MObexHeaderCheck::Reset()
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+/**
+This virtual function allows the M- classes to be extended in future in a binary
+compatible way by providing a method that clients can override in future to
+allow extra callbacks to be made via aObject.
+*/
+EXPORT_C void MObexHeaderCheck::MOHC_ExtensionInterfaceL(TUid /*aInterface*/, void*& aObject)
+ {
+ aObject = NULL;
+ }
+
+/**
+@return ETrue if this header is the requested one.
+
+@publishedAll
+@released
+*/
+EXPORT_C TBool TObexMatchHeader::Interested(TUint8 aHI)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return (aHI == iHI);
+ }
+
+/**
+Sets the header identifier required.
+@code : iHI = aHI;
+@publishedAll
+@released
+*/
+EXPORT_C void TObexMatchHeader::SetHeader(TUint8 aHI)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHI = aHI;
+ }
+
+/**
+@return ETrue if this header is of the requested type.
+@publishedAll
+@released
+*/
+EXPORT_C TBool TObexMatchHeaderType::Interested(TUint8 aHI)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return (ObexHeaderType(aHI) == iType);
+ }
+
+/**
+Set the header type required.
+@code : iType = aType;
+@publishedAll
+@released
+*/
+EXPORT_C void TObexMatchHeaderType::SetType(CObexHeader::THeaderType aType)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iType = aType;
+ }
+
+/**
+Creates an empty CObexHeaderSet object.
+@publishedAll
+@released
+*/
+EXPORT_C CObexHeaderSet* CObexHeaderSet::NewL()
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexHeaderSet* self = new(ELeave) CObexHeaderSet();
+ return self;
+ }
+
+/**
+Copies an existing CObexHeaderSet to populate a new object.
+@return A new CObexHeaderSet object populated with the headers.
+ This method returns ownership of the new object.
+@publishedAll
+@released
+*/
+EXPORT_C CObexHeaderSet* CObexHeaderSet::CopyL()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ CObexHeaderSet* newHeaderSet = new(ELeave) CObexHeaderSet();
+ CleanupStack::PushL(newHeaderSet);
+
+ TInt maxHeader = iHeaders.Count();
+ for (TInt pos = 0; pos < maxHeader; pos++)
+ {
+ CObexHeader* newHeader = iHeaders[pos]->CopyL();
+ CleanupStack::PushL(newHeader);
+ LEAVEIFERRORL(newHeaderSet->iHeaders.Append(newHeader));
+ CleanupStack::Pop(newHeader);
+ }
+
+ CleanupStack::Pop(newHeaderSet);
+ return newHeaderSet;
+ }
+
+/**
+Copies interesting headers from an existing CObexHeaderSet to populate a new object.
+@param aHeaderCheck The object to use to filter headers of interest.
+@return A new CObexHeaderSet object with the desired headers.
+ This method returns ownership of the new object.
+@publishedAll
+@released
+*/
+EXPORT_C CObexHeaderSet* CObexHeaderSet::CopyL(MObexHeaderCheck& aHeaderCheck)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ CObexHeaderSet* newHeaderSet = new(ELeave) CObexHeaderSet();
+ CleanupStack::PushL(newHeaderSet);
+
+ aHeaderCheck.Reset();
+
+ TInt maxHeader = iHeaders.Count();
+ for (TInt pos = 0; pos < maxHeader; pos++)
+ {
+ CObexHeader* header = iHeaders[pos];
+
+ if (aHeaderCheck.Interested(header->HI()))
+ {
+ CObexHeader* newHeader = header->CopyL();
+ CleanupStack::PushL(newHeader);
+ LEAVEIFERRORL(newHeaderSet->iHeaders.Append(newHeader));
+ CleanupStack::Pop(newHeader);
+ }
+ }
+
+ CleanupStack::Pop(newHeaderSet);
+ return newHeaderSet;
+ }
+
+/**
+Constructor
+*/
+CObexHeaderSet::CObexHeaderSet()
+ {
+ }
+
+/**
+Destructor
+This method deletes each individual item that the pointer array
+points at.
+
+@internalComponent
+*/
+CObexHeaderSet::~CObexHeaderSet()
+ {
+ iHeaders.ResetAndDestroy();
+ }
+
+/**
+Adds a header to the set.
+@param aHeader pointer to the header to be added. Ownership is transferred on a
+ successful addition.
+@return A standard error code giving the results of the insertion.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexHeaderSet::AddHeader(CObexHeader* aHeader)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ TInt ret = iHeaders.Append(aHeader);
+
+ return ret;
+ }
+
+/**
+Deletes the current header from the headerset.
+
+@publishedAll
+@released
+ */
+EXPORT_C void CObexHeaderSet::DeleteCurrentHeader()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if ((iPos >= 0) && (iPos < iHeaders.Count()))
+ {
+ delete iHeaders[iPos];
+ iHeaders.Remove(iPos);
+ }
+
+ First();
+ }
+
+/**
+Sets a header mask. Functions will only return values which the
+mask claims are interesting. The only 'accessor' functions which
+ignore this mask are the NewL overloads which copy an existing
+header set.
+
+The object defaults to a mask where all headers are considered
+interesting. Passing in a null parameter reverts to this behaviour.
+
+@param aMask The mask to use.
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeaderSet::SetMask(MObexHeaderCheck* aMask)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iMask = aMask;
+ First();
+ }
+
+/**
+Removes from this header set any headers which the mask claims are
+not interesting. The position of the iterator is reset to the first
+remaining header.
+The mask will get reset to zero at the end of this method.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeaderSet::DeleteMasked()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ First();
+
+ if (!iMask)
+ {
+ return;
+ }
+
+ TInt count = iHeaders.Count();
+ for (TInt pos = 0; pos < count; /*no iterative step*/)
+ {
+ TUint8 hi = iHeaders[pos]->HI();
+ if (!iMask->Interested(hi))
+ {
+ delete iHeaders[pos];
+ iHeaders.Remove(pos);
+ //do not increment pos as old [pos+1] element is now stored in [pos]
+ count--;
+ }
+ else
+ {
+ pos++;
+ }
+ }
+
+ iMask = 0;
+
+ First();
+ }
+
+/**
+Resets the mask, then advances the iterator to the first interesting header.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexHeaderSet::First() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iPos = 0;
+
+ if (iMask)
+ {
+ iMask->Reset();
+ }
+
+ if (Next(0) == KErrNotFound)
+ {
+ iPos = -1;
+ }
+ }
+
+/**
+Links the supplied header to the same underlying header that is used by the
+iterator's current header.
+@param aHeader The header object to populate.
+@return KErrNotFound if the iterator is not currently pointing to a valid
+ header.
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexHeaderSet::This(CObexHeader* aHeader) const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iPos < 0)
+ {
+ return KErrNotFound;
+ }
+
+ aHeader->Set(iHeaders[iPos]);
+ return KErrNone;
+ }
+
+/**
+Advances the iterator to the next interesting header, skipping over the current header before
+starting to search.
+@return KErrNotFound if there are no more interesting headers in the set.
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexHeaderSet::Next() const
+ {
+ return Next(1);
+ }
+
+/**
+Advances the iterator to the next interesting header, skipping over aSkip headers before
+starting to search.
+@param aSkip The minimum number of headers to move on from the current position,
+independant of whether a mask has been set or not.
+A value of zero therefore makes Next() essentially a no-op but presents the current
+header to the header filter again.
+@return KErrNotFound if there are no more interesting headers in the set.
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexHeaderSet::Next(TInt aSkip) const
+ {
+ // Don't log this function as it's too verbose.
+ //LOG_LINE
+ //LOG_FUNC
+
+ iPos += aSkip;
+ TInt count = iHeaders.Count();
+
+ if (iMask)
+ {
+ for (; iPos < count; iPos++)
+ {
+ TUint8 hi = iHeaders[iPos]->HI();
+ if (iMask->Interested(hi))
+ break;
+ }
+ }
+
+ if (iPos >= count)
+ {
+ iPos = -1;
+ }
+
+ return (iPos < 0) ? KErrNotFound : KErrNone;
+ }
+
+/**
+Returns the total number of headers in this set, ie. ignores the mask.
+@return Count of the total number of headers (masked and unmasked) in this set.
+@released
+*/
+EXPORT_C TInt CObexHeaderSet::Count() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iHeaders.Count();
+ }
+
+/**
+Returns the first instance of the header with the required HI value
+by inserting it into the supplied CObexHeader object. This uses the
+standard iterator functionality, so is limited by the current mask, and
+starts from the current iterator position.
+@param aHI The header to search for. Consult the Obex specification for values.
+@param aHeader The header object to populate.
+@return KErrNotFound if the header was not present.
+*/
+EXPORT_C TInt CObexHeaderSet::Find(TUint8 aHI, CObexHeader& aHeader) const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iPos >= iHeaders.Count())
+ {
+ // Already searched all available headers
+ return KErrNotFound;
+ }
+
+ if (iPos >= 0)
+ {
+ TUint8 hi = iHeaders[iPos]->HI();
+ TInt err = KErrNone;
+ while ((err == KErrNone) &&
+ (hi != aHI))
+ {
+ err = Next();
+ if (err == KErrNone)
+ {
+ hi = iHeaders[iPos]->HI();
+ }
+ }
+
+ if (hi == aHI)
+ {
+ aHeader.Set(iHeaders[iPos]);
+ return KErrNone;
+ }
+ else
+ {
+ return KErrNotFound;
+ }
+ }
+ else
+ {
+ return KErrNotFound;
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexheaderutil.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,209 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <obex/internal/obexinternalheader.h>
+#include <obexheaders.h>
+#include "obexheaderutil.h"
+
+/**
+This function wraps the potential leaving CreateAndSetUnicodeHeaderL function in a
+handy TRAP, because all the functions that call it are non-leavers.
+
+@param aHI is the Header Information byte for this new header (2 MSBits should indicate a Unicode header)
+@param aUnicode is the Header Value for this new header
+
+@return A pointer to a new CObexHeader, or NULL if the construction failed.
+*/
+CObexHeader* IrOBEXHeaderUtil::CreateAndSetUnicodeHeader(const TUint8 aHI, const TDesC16& aUnicode)
+ {
+ CObexHeader* header = NULL;
+ TRAP_IGNORE(header = CreateAndSetUnicodeHeaderL(aHI, aUnicode));
+ return header;
+ }
+
+/**
+Creates a new Unicode header, with value as specified by aHI and aUnicode. This function will
+leave if construction of the header fails.
+
+@param aHI is the Header Information byte for this new header (2 MSBits should indicate a Unicode header)
+@param aUnicode is the Header Value for this new header
+
+@return A pointer to a new CObexHeader.
+*/
+CObexHeader* IrOBEXHeaderUtil::CreateAndSetUnicodeHeaderL(const TUint8 aHI, const TDesC16& aUnicode)
+ {
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(aHI, aUnicode);
+ CleanupStack::Pop(header);
+ return header;
+ }
+
+/**
+This function wraps the potential leaving CreateAndSetByteSeqHeaderL function in a
+handy TRAP, because all the functions that call it are non-leavers.
+
+@param aHI is the Header Information byte for this new header (2 MSBits should indicate a Unicode header)
+@param aByteSeq is the Header Value for this new header
+
+@return A pointer to a new CObexHeader, or NULL if the construction failed.
+*/
+CObexHeader* IrOBEXHeaderUtil::CreateAndSetByteSeqHeader(const TUint8 aHI, const TDesC8& aByteSeq)
+ {
+ CObexHeader* header = NULL;
+ TRAP_IGNORE(header = CreateAndSetByteSeqHeaderL(aHI, aByteSeq));
+ return header;
+ }
+
+/**
+Creates a new Byte Sequence header, with value as specified by aHI and aByteSeq. This function will
+leave if construction of the header fails.
+
+@param aHI is the Header Information byte for this new header (2 MSBits should indicate a Unicode header)
+@param aByteSeq is the Header Value for this new header
+
+@return A pointer to a new CObexHeader.
+*/
+CObexHeader* IrOBEXHeaderUtil::CreateAndSetByteSeqHeaderL(const TUint8 aHI, const TDesC8& aByteSeq)
+ {
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(aHI, aByteSeq);
+ CleanupStack::Pop(header);
+ return header;
+ }
+
+TInt IrOBEXHeaderUtil::ParseHeader(TObexInternalHeader& aHeader, CObexHeaderSet& aHeaderSet)
+ {
+ TUint headerType = aHeader.HIType();
+
+ switch (headerType)
+ {
+ case (TObexInternalHeader::EUnicode) :
+ {
+ HBufC* newHeader = HBufC::New(aHeader.HVSize());
+ if (!newHeader)
+ {
+ return KErrNoMemory;
+ }
+ //else
+ TPtr ptr(newHeader->Des());
+
+ if(aHeader.GetHVText(ptr) == KErrNone)
+ {
+ CObexHeader* unicodeHeader = NULL;
+
+ unicodeHeader = IrOBEXHeaderUtil::CreateAndSetUnicodeHeader(aHeader.HI(), *newHeader);
+
+ if (!unicodeHeader)
+ {
+ delete newHeader;
+ newHeader = NULL;
+ return KErrNoMemory;
+ }
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ if (aHeaderSet.AddHeader(unicodeHeader) != KErrNone)
+ {
+ delete newHeader;
+ newHeader = NULL;
+ delete unicodeHeader;
+ unicodeHeader = NULL;
+ return KErrNoMemory;
+ }
+ }
+ delete newHeader;
+ newHeader = NULL;
+
+ break;
+ }
+
+ case (TObexInternalHeader::EByteSeq) :
+ {
+ TPtrC8 src(aHeader.HVByteSeq(), aHeader.HVSize());
+
+ CObexHeader* byteseqHeader = NULL;
+
+ byteseqHeader = IrOBEXHeaderUtil::CreateAndSetByteSeqHeader(aHeader.HI(), src);
+ if (!byteseqHeader)
+ {
+ return KErrNoMemory;
+ }
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ if (aHeaderSet.AddHeader(byteseqHeader) != KErrNone)
+ {
+ delete byteseqHeader;
+ byteseqHeader = NULL;
+ return KErrNoMemory;
+ }
+
+ break;
+ }
+
+ case (TObexInternalHeader::E1Byte) :
+ {
+ CObexHeader* byteHeader = NULL;
+ TRAPD(err, byteHeader=CObexHeader::NewL());
+ if (err)
+ {
+ return err;
+ }
+
+ byteHeader->SetByte(aHeader.HI(), (static_cast<TUint8>(aHeader.HVInt())));
+ //Transfer ownership of pointer to CObexHeaderSet
+ if(aHeaderSet.AddHeader(byteHeader) != KErrNone)
+ {
+ delete byteHeader;
+ byteHeader = NULL;
+ return KErrNoMemory;
+ }
+ break;
+ }
+
+ case (TObexInternalHeader::E4Byte) :
+ {
+ CObexHeader* fourByteHeader = NULL;
+ TRAPD(err, fourByteHeader = CObexHeader::NewL());
+ if (err)
+ {
+ return err;
+ }
+
+ fourByteHeader->SetFourByte(aHeader.HI(), aHeader.HVInt());
+ //Transfer ownership of pointer to CObexHeaderSet
+ if(aHeaderSet.AddHeader(fourByteHeader) != KErrNone)
+ {
+ delete fourByteHeader;
+ fourByteHeader = NULL;
+ return KErrNoMemory;
+ }
+ break;
+ }
+
+ default :
+ {
+ break;
+ }
+
+ } // End of switch
+
+ return KErrNone;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexnotifyhandlerbase.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,66 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexbase.h>
+#include "obexnotifyhandlerbase.h"
+
+/**
+@file
+@released
+@internalComponent
+*/
+
+/** Constructor.
+
+@param aObex The object to pass notifications to.
+*/
+CObexNotifyHandlerBase::CObexNotifyHandlerBase(CObex& aObex)
+ : iObex(aObex)
+ {
+ }
+
+/** Passes on Process notification.
+
+@param aPacket The packet to pass on to the CObex that will
+ handle this notification.
+*/
+void CObexNotifyHandlerBase::Process(CObexPacket& aPacket)
+ {
+ iObex.NotifyProcess(aPacket);
+ }
+
+/** Passes on Error notification.
+
+@param aError The error to pass on to the CObex that will
+ handle this notification.
+*/
+void CObexNotifyHandlerBase::Error(TInt aError)
+ {
+ iObex.NotifyError(aError);
+ }
+
+/** Passes on TransportUp notification.
+*/
+void CObexNotifyHandlerBase::TransportUp()
+ {
+ iObex.NotifyTransportUp();
+ }
+
+/** Passes on TransportDown notification.
+*/
+void CObexNotifyHandlerBase::TransportDown(TBool aForceTransportDeletion)
+ {
+ iObex.NotifyTransportDown(aForceTransportDeletion);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexnotifyhandlerclient.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,40 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+ @internalComponent
+*/
+
+#include "obexnotifyhandlerclient.h"
+
+/** Constructor.
+
+@param aObex The CObexClient to pass notifications onto.
+*/
+CObexNotifyHandlerClient::CObexNotifyHandlerClient(CObexClient& aObex)
+ : CObexNotifyHandlerBase(aObex)
+ {
+ }
+
+/** Signals that a packet process event has occurred.
+
+@param aEvent The event that has occurred.
+*/
+void CObexNotifyHandlerClient::SignalPacketProcessEvent(TObexPacketProcessEvent aEvent)
+ {
+ (static_cast<CObexClient&>(iObex)).SignalPacketProcessEvent(aEvent);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexnotifyhandlerserver.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,40 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+ @internalComponent
+*/
+
+#include "obexnotifyhandlerserver.h"
+
+/** Constructor.
+
+@param aObex The CObexServer to pass notifications onto.
+*/
+CObexNotifyHandlerServer::CObexNotifyHandlerServer(CObexServer& aObex)
+ : CObexNotifyHandlerBase(aObex)
+ {
+ }
+
+/** Signals that a packet process event has occurred.
+
+@param aEvent The event that has occurred.
+*/
+void CObexNotifyHandlerServer::SignalPacketProcessEvent(TObexPacketProcessEvent aEvent)
+ {
+ (static_cast<CObexServer&>(iObex)).SignalPacketProcessEvent(aEvent);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexobjectexpandedbaseobject.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,2361 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexpacket.h>
+#include "logger.h"
+#include "OBEXUTIL.H"
+#include "obexheaderutil.h"
+
+IF_FLOGGING(_LIT8(KLogComponent, "obex");)
+
+/**
+Default constructor for ObexObjects
+@internalComponent
+*/
+CObexBaseObject::CObexBaseObject()
+ {
+ ResetHeaders();
+ }
+
+/**
+Destructor.
+*/
+CObexBaseObject::~CObexBaseObject()
+ {
+ FLOG(_L("CObexBaseObject Destructor\r\n"));
+ ResetHeaders();
+ if (iObexHeader)
+ {
+ delete iObexHeader;
+ }
+
+ delete iHeaderSet;
+ }
+
+/**
+Sets header mask to 1's (include all), but valid mask to 0's (none valid).
+Also reset progress indicators to avoid any un-initialised transfer attempts
+@internalComponent
+*/
+void CObexBaseObject::ResetHeaders()
+ {
+ iHeaderMask = 0xFFFF;
+ iValidHeaders = 0x0000;
+ iSendProgress = EError;
+ iRecvProgress = EError;
+ iRecvBytes = 0;
+
+ if (iHttp)
+ {
+ iHttp->ResetAndDestroy();
+ delete iHttp;
+ iHttp = NULL;
+ }
+
+ // Here iHeaderSet can be NULL. This method is called in
+ // CObexBaseObject::CObexBaseObject() that is called before the
+ // derived class ConstructL() method. iHeaderSet is constructed in
+ // CreateHeaderStorageDataL() called from ConstructL().
+ // So, in the constructor it is always NULL.
+ // This method is also called in CObexBaseObject::Reset() where iHeaderSet
+ // will be valid.
+
+ if (iHeaderSet)
+ {
+ iHeaderSet->SetMask(NULL);
+ while (iHeaderSet->Count())
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+ }
+ }
+
+/**
+@internalComponent
+*/
+void CObexBaseObject::CreateHeaderStorageDataL()
+ {
+ __ASSERT_DEBUG(!iHeaderSet, IrOBEXUtil::Panic(ENotNullPointer));
+ iHeaderSet = CObexHeaderSet::NewL();
+
+ if (iObexHeader == NULL)
+ {
+ iObexHeader = CObexHeader::NewL();
+ }
+ }
+
+/**
+Set the connection id.
+This method will check the headerset for a connectionId header. If one if located,
+then this will be modified for the new HV value. If not, a new connectionId header
+will be added.
+
+@param aFourByte The connectionID to be set
+@internalComponent
+*/
+void CObexBaseObject::SetConnectionIdL(TUint32 aFourByte)
+ {
+ FLOG(_L(">>CObexBaseObject::SetConnectionIdL"));
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::EConnectionID, *iObexHeader) == KErrNone)
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(TObexInternalHeader::EConnectionID, aFourByte);
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+ CleanupStack::Pop(header);
+
+ iValidHeaders |= KObexHdrConnectionID;
+ iHeaderMask |= KObexHdrConnectionID;
+
+ FLOG(_L("<<CObexBaseObject::SetConnectionIdL"));
+ }
+
+/**
+Returns the connection ID.
+
+@return Returns KConnIDInvalid if no connectionID is set.
+@internalComponent
+*/
+TUint32 CObexBaseObject::ConnectionID()
+ {
+ if (iValidHeaders & KObexHdrConnectionID)
+ {
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::EConnectionID, *iObexHeader) == KErrNone)
+ {
+ return (iObexHeader->AsFourByte());
+ }
+ else
+ {
+ return KConnIDInvalid;
+ }
+ }
+ else
+ {
+ return KConnIDInvalid;
+ }
+ }
+
+/**
+Sets the Name attribute of the object.
+
+The Name is used to identify the object to the remote machine (or to identify
+a received object). Note that in general, this is quite distinct from the
+CObexFileObject::DataFile() attribute, which specifies where the body of the
+object is stored.
+
+@param aDesc Name attribute
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetNameL (const TDesC& aDesc)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::EName, *iObexHeader) == KErrNone)
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(TObexInternalHeader::EName, aDesc);
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+ CleanupStack::Pop(header);
+
+ iValidHeaders |= KObexHdrName;
+ }
+
+/**
+Sets the Type attribute of the object.
+
+This should be in the form of a valid IANA media type (see http://www.iana.org/assignments/media-types/index.html).
+
+@param aDesc Type attribute
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetTypeL (const TDesC8& aDesc)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ TInt len = aDesc.Length();
+ // make sure length does not include any null terms
+ while(len && aDesc[len - 1] == 0)
+ {
+ --len;
+ };
+ TPtrC8 src = aDesc.Left(len);
+
+ //leave room for exactly one null term
+ HBufC8* buf = HBufC8::NewL(src.Length() + 1);
+ CleanupStack::PushL(buf);
+ TPtr8 type(buf->Des());
+ type.Copy(src);
+ type.Append(0);
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::EType, *iObexHeader) == KErrNone)
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(TObexInternalHeader::EType, type);
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+ CleanupStack::Pop(header);
+
+ CleanupStack::PopAndDestroy(buf);
+
+ iValidHeaders |= KObexHdrType;
+
+ }
+
+/**
+Sets the Length attribute of the object, in bytes.
+
+Note that this does not necessarily have to match the exact size of the body
+data, but is used to give an indication of the size to the receiving end.
+
+@param aLength Length attribute of the object
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetLengthL (const TUint32 aLength)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::ELength, *iObexHeader) == KErrNone)
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(TObexInternalHeader::ELength, aLength);
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+ CleanupStack::Pop(header);
+
+ iValidHeaders |= KObexHdrLength;
+ }
+
+/**
+Sets the Time attribute of the object (stored in UTC).
+
+@param aLocalTime Time attribute in local time
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetTimeL (const TTime aLocalTime)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // Convert local time to UTC
+ TTime utcTime(aLocalTime);
+ utcTime -= User::UTCOffset();
+ SetUtcTimeL(utcTime);
+ }
+
+/**
+Sets the Time attribute of the object (stored in UTC).
+
+@param aUtcTime Time attribute in local time
+*/
+void CObexBaseObject::SetUtcTimeL (const TTime aUtcTime)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ TBuf<16> timebuf;
+ aUtcTime.FormatL(timebuf, _L("%F%Y%M%DT%H%T%SZ"));
+ TBuf8<16> narrowBuf;
+ narrowBuf.Copy(timebuf);
+ SetTimeHeaderL(narrowBuf);
+
+ iValidHeaders |= KObexHdrTime;
+ }
+
+/**
+Add a descriptor as the one and only Time header in an object.
+
+@param aTimeDes A narrow descriptor which will be stored in the object.
+*/
+void CObexBaseObject::SetTimeHeaderL(const TDesC8& aTimeDes)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::ETime, *iObexHeader) == KErrNone)
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(TObexInternalHeader::ETime, aTimeDes);
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+ CleanupStack::Pop(header);
+ }
+
+/**
+Sets the Description attribute of the object.
+
+This is currently the easiest way to send proprietary information along with
+an object.
+
+@param aDesc Description attribute
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetDescriptionL (const TDesC& aDesc)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::EDescription, *iObexHeader) == KErrNone)
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(TObexInternalHeader::EDescription, aDesc);
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+ CleanupStack::Pop(header);
+
+ iValidHeaders |= KObexHdrDescription;
+ }
+
+/**
+Sets the Application Parameters attribute of the object.
+
+ This is expected to be of the format Tag-Length-Value, but this is not enforced.
+
+@param aDesc Application Parameters attribute
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetAppParamL (const TDesC8& aDesc)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ FLOG(_L("CObexBaseObject::SetAppParamL"));
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::EAppParam, *iObexHeader) == KErrNone)
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(TObexInternalHeader::EAppParam, aDesc);
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+ CleanupStack::Pop(header);
+
+ iValidHeaders |= KObexHdrAppParam;
+ }
+
+/**
+Sets the Target attribute of the object.
+
+Generally, this will only have any useful meaning if the session Who attribute
+of the remote machine is recognised, and particularly, when connected to a
+strict peer (see CObex::IsStrictPeer()).
+
+@param aDesc Target attribute
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::SetTargetL (const TDesC8& aDesc)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::ETarget, *iObexHeader) == KErrNone)
+ {
+ iHeaderSet->DeleteCurrentHeader();
+ }
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(TObexInternalHeader::ETarget, aDesc);
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+ CleanupStack::Pop(header);
+
+ iValidHeaders |= KObexHdrTarget;
+ }
+
+/**
+Add an Http header.
+
+@param aDesc HTTP header to be added to the object's collection of HTTP headers
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::AddHttpL (const TDesC8& aDesc)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(TObexInternalHeader::EHttp, aDesc);
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(header));
+ CleanupStack::Pop(header);
+
+ if (!iHttp)
+ {
+ iHttp = new(ELeave) RPointerArray<HBufC8>(2);
+ }
+
+ HBufC8* buf = aDesc.AllocLC();
+ LEAVEIFERRORL(iHttp->Append(buf));
+ CleanupStack::Pop(buf);
+
+ iValidHeaders |= KObexHdrHttp;
+ }
+
+/**
+Adds a CObexHeader into the CObexHeaderSet
+
+@param aHeader A Pointer to a CObexHeader to be added to the CObexHeaderSet
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::AddHeaderL(CObexHeader& aHeader)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (aHeader.HI() == TObexInternalHeader::EHttp)
+ {
+ // Add the HTTP header into the iHttp array to keep old and new
+ // http header storage consistent.
+ //
+ if (!iHttp)
+ {
+ iHttp = new(ELeave) RPointerArray<HBufC8>(2);
+ }
+
+ HBufC8* buf = (aHeader.AsByteSeq()).AllocLC();
+ LEAVEIFERRORL(iHttp->Append(buf));
+ CleanupStack::Pop();
+
+ iValidHeaders |= KObexHdrHttp;
+ }
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ LEAVEIFERRORL(iHeaderSet->AddHeader(&aHeader));
+
+ switch (aHeader.HI())
+ {
+ case (TObexInternalHeader::EName) :
+ {
+ iValidHeaders |= KObexHdrName;
+ break;
+ }
+ case (TObexInternalHeader::EType) :
+ {
+ iValidHeaders |= KObexHdrType;
+ break;
+ }
+ case (TObexInternalHeader::ETime) :
+ {
+ iValidHeaders |= KObexHdrTime;
+ break;
+ }
+ case (TObexInternalHeader::EConnectionID) :
+ {
+ iValidHeaders |= KObexHdrConnectionID;
+ break;
+ }
+ case (TObexInternalHeader::ELength) :
+ {
+ iValidHeaders |= KObexHdrLength;
+ break;
+ }
+ case (TObexInternalHeader::EDescription) :
+ {
+ iValidHeaders |= KObexHdrDescription;
+ break;
+ }
+ case (TObexInternalHeader::ECount) :
+ {
+ iValidHeaders |= KObexHdrCount;
+ break;
+ }
+ case (TObexInternalHeader::EAppParam) :
+ {
+ iValidHeaders |= KObexHdrAppParam;
+ break;
+ }
+ case (TObexInternalHeader::ETarget) :
+ {
+ iValidHeaders |= KObexHdrTarget;
+ break;
+ }
+ case (TObexInternalHeader::ECreatorID) :
+ {
+ iValidHeaders |= KObexHdrCreatorID;
+ break;
+ }
+ case (TObexInternalHeader::EWanUUID) :
+ {
+ iValidHeaders |= KObexHdrWanUUID;
+ break;
+ }
+ case (TObexInternalHeader::EObjectClass) :
+ {
+ iValidHeaders |= KObexHdrObjectClass;
+ break;
+ }
+ case (TObexInternalHeader::EEndOfBody) :
+ {
+ __ASSERT_ALWAYS(DataSize() == 0, IrOBEXUtil::Panic(EAddingInvalidEoBHeader));
+ iValidHeaders |= KObexHdrEndOfBody;
+ break;
+ }
+ default :
+ {
+ if ((aHeader.HI() & 0x30) != 0)
+ {
+ iValidHeaders |= KObexHdrUserDefined;
+ }
+ break;
+ }
+ }
+ }
+
+/**
+Resets the object, to make it represent nothing.
+
+Call this before setting a CObexObject to represent a new object.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBaseObject::Reset()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ ResetHeaders();
+ ResetData();
+ }
+
+/**
+Makes a first level guess at setting the mime type from the
+file extension.
+
+This API is deprecated and may be removed at any time. For any production
+applications, the versit and the Application architecture (see
+RApaLsSession::RecognizeData) provide far more flexibilty and robustness.
+
+@deprecated 6.1
+@internalComponent
+*/
+void CObexBaseObject::GuessTypeFromExtL(const TDesC& aExt)
+ {
+ _LIT(KVcfType, ".vcf");
+ _LIT(KVcsType, ".vcs");
+ _LIT(KTxtType, ".txt");
+ _LIT8(KVcard, "text/x-vCard");
+ _LIT8(KVcalendar, "text/x-vCalendar");
+ _LIT8(KTextPlain, "text/plain");
+
+ iValidHeaders &= ~KObexHdrType; // Default, if no others match
+ if(!aExt.CompareC(KVcfType))
+ {
+ SetTypeL(KVcard);
+ return;
+ }
+ if(!aExt.CompareC(KVcsType))
+ {
+ SetTypeL(KVcalendar);
+ return;
+ }
+ if(!aExt.CompareC(KTxtType))
+ {
+ SetTypeL(KTextPlain);
+ return;
+ }
+ }
+
+/**
+Gets the object's Name attribute.
+
+@return Object's Name attribute or KNullDesC if it has not been set
+
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC& CObexBaseObject::Name()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iValidHeaders & KObexHdrName)
+ {
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ // search for a Name header in the headerset
+ if (iHeaderSet->Find(TObexInternalHeader::EName, *iObexHeader) == KErrNone)
+ {
+ //header is found so return the HV as Unicode
+ return (iObexHeader->AsUnicode());
+ }
+ else
+ {
+ return (KNullDesC);
+ }
+ }
+ else
+ {
+ return (KNullDesC);
+ }
+ }
+
+/**
+Gets the object's Type attribute.
+
+@return Object's Type attribute or KNullDesC8 if it has not been set
+
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC8& CObexBaseObject::Type()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iValidHeaders & KObexHdrType)
+ {
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ // search for a Type header in the headerset
+ if (iHeaderSet->Find(TObexInternalHeader::EType, *iObexHeader) == KErrNone)
+ {
+ //header is found so return the HV as ByteSequence
+ return (iObexHeader->AsByteSeq());
+ }
+ else
+ {
+ return (KNullDesC8);
+ }
+ }
+ else
+ {
+ return (KNullDesC8);
+ }
+ }
+
+/**
+Gets the object's Length attribute.
+
+Note this might not match the size of the file (if any) to transfer.
+
+@return Object's Length attribute or 0 if it has not been set
+
+@publishedAll
+@released
+*/
+EXPORT_C TUint32 CObexBaseObject::Length()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iValidHeaders & KObexHdrLength)
+ {
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ // search for a Length header in the headerset
+ if (iHeaderSet->Find(TObexInternalHeader::ELength, *iObexHeader) == KErrNone)
+ {
+ //header is found so return the HV as FourByte
+ return (iObexHeader->AsFourByte());
+ }
+ else
+ {
+ return (0);
+ }
+ }
+ else
+ {
+ return (0);
+ }
+ }
+
+/**
+Firstly updates the iHttp list, ensuring that the entries are
+the same as those HTTP headers within the header set.
+(The iHttp list could have contained old headers that were removed from
+the headerset using the DeleteMasked operation)
+Returns a pointer to the Http header array or null if no headers defined.
+@return A pointer to the Http header array or null if no headers defined
+
+@publishedAll
+@released
+**/
+EXPORT_C const RPointerArray<HBufC8>* CObexBaseObject::Http() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // if there are headers in the iHttp list
+ if (iHttp && (iHttp->Count()))
+ {
+
+ TInt httpCount = 0;
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ TInt err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+ while (err == KErrNone)
+ {
+ httpCount++;
+ err = iHeaderSet->Next();
+ if (!err)
+ {
+ err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+ }
+ }
+
+ // check if number of HTTP in iHttp equals number in header set
+ // NB. if equal then they must be the same headers due to the way that the
+ // addition of HTTP headers has been implemented (ie. both AddHttpL and
+ // AddHeader for Http, will update the iHTTP list, as well as HeaderSet)
+ //
+ if (httpCount != (iHttp->Count()))
+ {
+ // reset the header iterator to the start of the headerset
+ iHeaderSet->First();
+
+ TInt arrayIndex = 0;
+
+ // search for an Http header in the headerset
+ err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+
+ while (err == KErrNone)
+ {
+ //delete items from the iHttp list until an HTTP header with the same HV value
+ //as the HTTP header in the headerset has been located.
+ while ((iObexHeader->AsByteSeq()) != (((*iHttp)[arrayIndex])->Des()))
+ {
+ delete (*iHttp)[arrayIndex];
+ (*iHttp).Remove(arrayIndex);
+ }
+
+ arrayIndex++;
+
+ // search for an Http header in the headerset
+ iHeaderSet->Next();
+ err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+ }
+
+ // if the number of HTTP headers in the headerset is different to the iHTTP count
+ // then there must be some remaining headers at the end of the list, so remove
+ // them
+ while (httpCount < (iHttp->Count()))
+ {
+ delete (*iHttp)[arrayIndex];
+ (*iHttp).Remove(arrayIndex);
+ }
+ }
+
+ // if there are no elements in the iHttp list, delete the list and return NULL
+ if (iHttp->Count() == 0)
+ {
+ if (iHttp)
+ {
+ iHttp->ResetAndDestroy();
+ delete iHttp;
+ iHttp = NULL;
+ }
+
+ return NULL;
+ }
+ else
+ {
+ //return the iHttp pointer
+ return iHttp;
+ }
+ }
+ else //iHttp && iHttp->Count
+ {
+ return NULL;
+ }
+ }
+
+/**
+Take time string specified in ISO8601 format and convert to a TTime
+@param aTime Time descriptor in ISO8601 format
+@param aResult Object to place resultant local time. Set to 0 if conversion fails.
+*/
+void ParseISO8601Time(const TDesC& aTimeDes, TTime& aResult)
+ {
+ LOG_STATIC_FUNC_ENTRY
+ FLOG(_L8("Parsing ISO 8601 format time"));
+
+ TInt yr, mn, dy, hr, mi, sc;
+ TLex lex(aTimeDes);
+ aResult = 0; // return TTime(0) by default
+
+ // Get date components
+ TUint num;
+ if (lex.Val(num) != KErrNone)
+ {
+ FLOG(_L8("Date not found"));
+ return;
+ }
+
+ dy = num % 100;
+ num /= 100;
+ mn = num % 100;
+ num /= 100;
+ yr = num;
+
+ if (lex.Get() != 'T')
+ {
+ FLOG(_L8("Char 'T' not found"));
+ return;
+ }
+
+ // Get time components
+ if (lex.Val(num) != KErrNone)
+ {
+ FLOG(_L8("Time not found"));
+ return;
+ }
+ sc = num % 100;
+ num /= 100;
+ mi = num % 100;
+ num /= 100;
+ hr = num;
+
+ // Convert components into a TTime
+ TDateTime dt;
+ if (dt.Set(yr,TMonth(mn-1),(dy-1),hr,mi,sc,0) != KErrNone) // day and month are zero based in TDateTime::Set
+ {
+ FLOG(_L8("Failed to convert time"));
+ return;
+ }
+ aResult = dt;
+
+ // If time is in UTC, convert to local time
+ if (lex.Get() == 'Z')
+ {
+ aResult += User::UTCOffset(); // includes any daylight saving correction
+ }
+ }
+
+/**
+Returns the time attribute of the object in local time.
+Returns TTime (0) if no valid time has been set.
+
+@return Object's Time attribute in local time or TTime(0) if it has not been set
+
+@publishedAll
+@released
+**/
+EXPORT_C const TTime CObexBaseObject::Time()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ TTime newTime = TTime(0);
+
+ if (iValidHeaders & KObexHdrTime)
+ {
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::ETime, *iObexHeader) == KErrNone)
+ {
+ TBuf16<16> localbuf;
+ localbuf.Copy(iObexHeader->AsByteSeq());
+
+ ParseISO8601Time(localbuf, newTime);
+ }
+ }
+ return newTime;
+ }
+
+/**
+Gets the object's Description attribute.
+
+@return Object's Name attribute or KNullDesC if it has not been set
+
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC& CObexBaseObject::Description()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iValidHeaders & KObexHdrDescription)
+ {
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ // search for a Description header in the headerset
+ if (iHeaderSet->Find(TObexInternalHeader::EDescription, *iObexHeader) == KErrNone)
+ {
+ //header is found so return the HV as Unicode
+ return (iObexHeader->AsUnicode());
+ }
+ else
+ {
+ return (KNullDesC);
+ }
+ }
+ else
+ {
+ return (KNullDesC);
+ }
+ }
+
+/**
+Gets the object's Application Parameters attribute
+
+This function does not parse the Application Parameters attribute into the
+expected Tag-Length-Value format.
+
+@return Object's Application Parameters attribute, or KNullDesC8 if none has been set
+
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC8& CObexBaseObject::AppParam() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iValidHeaders & KObexHdrAppParam)
+ {
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ // search for a AppParam header in the headerset
+ if (iHeaderSet->Find(TObexInternalHeader::EAppParam, *iObexHeader) == KErrNone)
+ {
+ //header is found so return the HV as ByteSeq
+ return (iObexHeader->AsByteSeq());
+ }
+ else
+ {
+ return (KNullDesC8);
+ }
+ }
+ else
+ {
+ return (KNullDesC8);
+ }
+ }
+
+/**
+Gets the object's Target attribute.
+
+@return Object's Target attribute or KNullDesC8 if it has not been set
+
+@publishedAll
+@released
+*/
+EXPORT_C const TDesC8& CObexBaseObject::Target()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iValidHeaders & KObexHdrTarget)
+ {
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ // search for a Target header in the headerset
+ if (iHeaderSet->Find(TObexInternalHeader::ETarget, *iObexHeader) == KErrNone)
+ {
+ //header is found so return the HV as ByteSeq
+ return (iObexHeader->AsByteSeq());
+ }
+ else
+ {
+ return (KNullDesC8);
+ }
+ }
+ else
+ {
+ return (KNullDesC8);
+ }
+ }
+
+/**
+@publishedAll
+@released
+@return A const reference to the HeaderSet object used by this object.
+@see CObexHeaderSet
+*/
+EXPORT_C const CObexHeaderSet& CObexBaseObject::HeaderSet() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return *iHeaderSet;
+ }
+
+/**
+@publishedAll
+@released
+@return A reference to the HeaderSet object used by this object.
+@see CObexHeaderSet
+*/
+EXPORT_C CObexHeaderSet& CObexBaseObject::HeaderSet()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return *iHeaderSet;
+ }
+
+/**
+Prepare the object for sending. Each packet sent will contain aOpcode.
+
+@param aOpcode
+@return KErrNone
+@internalComponent
+*/
+TInt CObexBaseObject::InitSend(TObexOpcode aOpcode)
+ {
+ FLOG(_L("CObexBaseObject::InitSend"));
+
+ iSendHeaders = 0;
+ iSendBytes = 0;
+ iSendOpcode = aOpcode;
+ iSendProgress = EContinue;
+
+ return KErrNone;
+ }
+
+/**
+Fill up the Connect command with the appropriate headers.
+
+@param aPacket The packet to be filled
+@internalComponent
+*/
+void CObexBaseObject::PrepareConnectionHeader(CObexPacket &aPacket)
+ {
+ FLOG(_L("CObexBaseObject::PrepareConnectionHeader\r\n"));
+ TObexInternalHeader header;
+
+ TObexHeaderMask remaininghdr = static_cast<TObexHeaderMask>(iValidHeaders & iHeaderMask);
+ if(remaininghdr)
+ {// ...there are some valid, unsent headers left to send.
+ //the Target header should be sent first
+ if(remaininghdr & KObexHdrTarget)
+ {
+ FLOG(_L("PrepareConnectionHeader - Preparing Target Header\r\n"));
+
+ if ( Target() != KNullDesC8 )
+ {
+ header.Set(TObexInternalHeader::ETarget, (const_cast<TUint8*>(Target().Ptr())), Target().Size());
+
+ if(aPacket.InsertData(header))
+ {
+ iSendHeaders |= KObexHdrTarget;
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ }
+ }
+ }
+ }
+ }
+
+/**
+Fill up aPacket with whatever is left to be sent of the object.
+Trys to get attribute headers out asap,
+and tacks as much of the data part of the object onto the end of each
+packet as will fit. Returned value goes to EComplete on the call *after*
+the final packet has been written(i.e. indicates nothing left to do).
+
+@param aPacket The packet to be filled
+@return Progress in writing out the object
+@internalComponent
+*/
+CObexBaseObject::TProgress CObexBaseObject::PrepareNextSendPacket(CObexPacket &aPacket)
+ {
+ FLOG(_L("CObexBaseObject::PrepareNextSendPacket\r\n"));
+
+ // iHeaderSet is often dereferenced in this method. So it worth to check it
+ // at the beginning
+
+ __ASSERT_DEBUG(iHeaderSet, IrOBEXUtil::Panic(ENullPointer));
+
+ if(iSendProgress == ELastPacket)
+ {
+ /*
+ If the state was 'ELastPacket' as a result of the
+ last call to this method, then the last packet will
+ now have been sent!
+ */
+ iSendProgress = EComplete;
+ }
+
+ if(iSendProgress != EContinue)
+ {
+ FLOG(_L("PrepareNextSendPacket - immediate exit\r\n"));
+ return(iSendProgress);
+ }
+
+ TObexInternalHeader header;
+ aPacket.Init(iSendOpcode);
+ TInt startspace = aPacket.RemainingInsertSpace();
+
+ TObexHeaderMask remaininghdr = static_cast<TObexHeaderMask>(~iSendHeaders & iValidHeaders & iHeaderMask);
+ TBool suppressDataHeader = EFalse;
+ TBool firstHeader = ETrue;
+ if(remaininghdr)
+ {// ...there are some valid, unsent headers left to send.
+ if(remaininghdr & KObexHdrTarget)
+ {
+ FLOG(_L("PrepareConnectionHeader - Preparing Target Header\r\n"));
+
+ header.Set(TObexInternalHeader::ETarget, (const_cast<TUint8*> (Target().Ptr())), Target().Size());
+ if(aPacket.InsertData(header))
+ {
+ iSendHeaders |= KObexHdrTarget;
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+
+ if (remaininghdr & KObexHdrConnectionID)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing EConnectionID header\r\n"));
+
+ TUint32 connID = ConnectionID();
+ if ( connID != KConnIDInvalid )
+ {
+
+ TUint32 newConnectionID = connID;
+ header.Set(TObexInternalHeader::EConnectionID, newConnectionID);
+
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ iSendHeaders |= KObexHdrConnectionID;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrConnectionID;
+ }
+ }
+
+ if(remaininghdr & KObexHdrName)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing EName header\r\n"));
+
+ header.Set(TObexInternalHeader::EName, Name());
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ iSendHeaders |= KObexHdrName;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+
+ if(remaininghdr & KObexHdrLength)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing ELength header\r\n"));
+
+ header.Set(TObexInternalHeader::ELength, Length());
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ iSendHeaders |= KObexHdrLength;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+ if(remaininghdr & KObexHdrType)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing EType header\r\n"));
+
+ header.Set(TObexInternalHeader::EType, (const_cast<TUint8*> (Type().Ptr())), Type().Size());
+
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ iSendHeaders |= KObexHdrType;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+
+ if(remaininghdr & KObexHdrDescription)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing EDescription header\r\n"));
+
+ header.Set(TObexInternalHeader::EDescription, Description());
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ iSendHeaders |= KObexHdrDescription;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+ if(remaininghdr & KObexHdrCount)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing ECount header\r\n"));
+
+ if (iValidHeaders & KObexHdrCount)
+ {
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::ECount, *iObexHeader) == KErrNone)
+ {
+
+ TUint32 newCount = iObexHeader->AsFourByte();
+ header.Set(TObexInternalHeader::ECount, newCount);
+
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ iSendHeaders |= KObexHdrCount;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrCount;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrCount;
+ }
+ }
+ if (remaininghdr & KObexHdrAppParam)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing EAppParam header\r\n"));
+
+ header.Set(TObexInternalHeader::EAppParam, (const_cast<TUint8*> (AppParam().Ptr())), AppParam().Size());
+
+ if (aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ iSendHeaders |= KObexHdrAppParam;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+
+ if (remaininghdr & KObexHdrHttp)
+ {
+ //no need to check iValidHeaders as if it is false then remaininghdr would be too.
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ TBool headerFound = EFalse;
+ TUint headerFoundCount = 0;
+ TUint headerHandledCount = 0;
+
+ TInt err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+
+ while (err == KErrNone)
+ {
+ headerFoundCount++;
+
+ if ( (!(iObexHeader->Attributes() & CObexHeader::ESent)) &&
+ (!(iObexHeader->Attributes() & CObexHeader::ESuppressed)) )
+ {
+ //Unsent and Unsuppressed Http header had been found
+ headerFound = ETrue;
+
+ header.Set(TObexInternalHeader::EHttp, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+ headerHandledCount++;
+
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ else if (firstHeader)
+ {
+ // Had problems inserting the first HTTP header, Set it to suppressed.
+ // (this is also the first header in the packet, so we had the full
+ // packet size available)
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESuppressed));
+ headerHandledCount++;
+ }
+ }
+ else
+ {
+ //Header has previously been sent/suppressed
+ headerHandledCount++;
+ }
+
+ iHeaderSet->Next();
+ err = iHeaderSet->Find(TObexInternalHeader::EHttp, *iObexHeader);
+ }
+
+ if (headerFoundCount == headerHandledCount)
+ {
+ //All HTTP headers have been sent (or suppressed)
+ iSendHeaders |= KObexHdrHttp;
+ }
+
+ // an unsent http header cannot be found in headerset so set flag to invalid
+ if (headerFound == EFalse)
+ {
+ iValidHeaders &= ~KObexHdrHttp;
+ }
+ }
+
+ if(remaininghdr & KObexHdrCreatorID)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing ECreatorID header\r\n"));
+
+ if (iValidHeaders & KObexHdrCreatorID)
+ {
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::ECreatorID, *iObexHeader) == KErrNone)
+ {
+ header.Set(TObexInternalHeader::ECreatorID, iObexHeader->AsFourByte());
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+ iSendHeaders |= KObexHdrCreatorID;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrCreatorID;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrCreatorID;
+ }
+ }
+
+ if(remaininghdr & KObexHdrWanUUID)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing EWanUUID header\r\n"));
+ if (iValidHeaders & KObexHdrWanUUID)
+ {
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::EWanUUID, *iObexHeader) == KErrNone)
+ {
+ header.Set(TObexInternalHeader::EWanUUID, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+ iSendHeaders |= KObexHdrWanUUID;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrWanUUID;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrWanUUID;
+ }
+ }
+
+ if(remaininghdr & KObexHdrObjectClass)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing EObjectClass header\r\n"));
+ if (iValidHeaders & KObexHdrObjectClass)
+ {
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::EObjectClass, *iObexHeader) == KErrNone)
+ {
+ header.Set(TObexInternalHeader::EObjectClass, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ iSendHeaders |= KObexHdrObjectClass;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrObjectClass;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrObjectClass;
+ }
+ }
+ if (remaininghdr & KObexHdrUserDefined)
+ {
+ TBool headerFound = EFalse;
+ TUint headerFoundCount = 0;
+ TUint headerSentCount = 0;
+ TInt err = 0;
+
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ for (TUint8 headerTypeIndex = TObexInternalHeader::EUnicode;
+ headerTypeIndex <= TObexInternalHeader::E4Byte;)
+ // NB. iterative step not included in this for loop, this is done at the end
+ //of the for loop: moves headerTypeIndex to the next type
+ {
+
+ for (TUint8 headerNameIndex = KObexUserDefinedHdrAddrMin;
+ headerNameIndex <= KObexUserDefinedHdrAddrMax; headerNameIndex++)
+ {
+ TUint8 localHI = static_cast<TUint8>(headerTypeIndex | headerNameIndex);
+
+ iHeaderSet->First();
+
+ err = iHeaderSet->Find(localHI, *iObexHeader);
+
+ if (err == KErrNone)
+ {
+ headerFoundCount++;
+
+ if ((iObexHeader->Attributes() & CObexHeader::ESent) == 0)
+ {
+ headerFound = ETrue;
+
+ switch (headerTypeIndex)
+ {
+ case (TObexInternalHeader::EUnicode) :
+ {
+ header.Set(localHI, iObexHeader->AsUnicode());
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ headerSentCount++;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+
+ break;
+ }
+ case (TObexInternalHeader::EByteSeq) :
+ {
+ header.Set(localHI, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ headerSentCount++;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ break;
+ }
+ case (TObexInternalHeader::E1Byte) :
+ {
+ header.Set(localHI, iObexHeader->AsByte());
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ headerSentCount++;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ break;
+ }
+ case (TObexInternalHeader::E4Byte) :
+ {
+ header.Set(localHI, iObexHeader->AsFourByte());
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ headerSentCount++;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ break;
+ }
+ default :
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ //header has been previously sent.
+ headerSentCount++;
+ }
+ }// header not found in headerset
+
+ } //for loop: user defined header 'name' addresses
+
+ // set the header type to the next
+ //
+ switch (headerTypeIndex)
+ {
+ case (TObexInternalHeader::EUnicode) :
+ {
+ headerTypeIndex = TObexInternalHeader::EByteSeq;
+ break;
+ }
+ case (TObexInternalHeader::EByteSeq) :
+ {
+ headerTypeIndex = TObexInternalHeader::E1Byte;
+ break;
+ }
+ case (TObexInternalHeader::E1Byte) :
+ {
+ headerTypeIndex = TObexInternalHeader::E4Byte;
+ break;
+ }
+ case (TObexInternalHeader::E4Byte) :
+ {
+ headerTypeIndex++; // incrementing this past E4Byte will cause for loop to exit
+ break;
+ }
+ default : {break;}
+ }
+ }//for loop: user defined header 'type' addresses
+
+ if (headerFoundCount == headerSentCount)
+ {
+ //All User defined headers have been sent
+ iSendHeaders |= KObexHdrUserDefined;
+ }
+
+ // an unsent user defined header cannot be found in headerset so set flag to invalid
+ if (headerFound == EFalse)
+ {
+ iValidHeaders &= ~KObexHdrUserDefined;
+ }
+ }
+
+ if(remaininghdr & KObexHdrTime)
+ {// Must be last, due to Windows 2000 parse bug (see defect v3 EDNJKIN-4N4G7K)
+ if (iValidHeaders & KObexHdrTime)
+ {
+ FLOG(_L("PrepareNextSendPacket - preparing ETime header\r\n"));
+ //reset the mask so all headers are searched
+ //NB. SetMask sets the iterator at the start of the headerset
+ iHeaderSet->SetMask(NULL);
+
+ if (iHeaderSet->Find(TObexInternalHeader::ETime, *iObexHeader) == KErrNone)
+ {
+ header.Set(TObexInternalHeader::ETime, (const_cast<TUint8*> ((iObexHeader->AsByteSeq()).Ptr())), (iObexHeader->AsByteSeq()).Size());
+ if(aPacket.InsertData(header))
+ {
+ //set that a header has been added to this current packet
+ iSendHeaders |= KObexHdrTime;
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ suppressDataHeader = ETrue; // Win2000 Bug work-aroung
+ firstHeader = EFalse;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrTime;
+ }
+ }
+ else
+ {
+ iValidHeaders &= ~KObexHdrTime;
+ }
+ }
+
+ remaininghdr = STATIC_CAST(TObexHeaderMask, ~iSendHeaders & iValidHeaders & iHeaderMask);
+
+ // Only add EoB if there is no other remaining headers
+ if (remaininghdr == KObexHdrEndOfBody)
+ {
+ //EoB can only be added in Empty objects.
+ __ASSERT_ALWAYS(DataSize() == 0, IrOBEXUtil::Panic(EAddingInvalidEoBHeader));
+ header.SetHI(TObexInternalHeader::EEndOfBody);
+
+ if(aPacket.InsertData(header))
+ {
+ iObexHeader->SetAttributes(static_cast<TUint16>(iObexHeader->Attributes() | CObexHeader::ESent));
+
+ iSendHeaders |= KObexHdrEndOfBody;
+ //set that a header has been added to this current packet
+ firstHeader = EFalse;
+ }
+ else if(aPacket.RemainingInsertSpace() != startspace) //something has been added
+ {
+ //There is no enough space for EOB this round, try again next time
+ return EContinue;
+ }
+ //else if nothing has been added, EError will be returned
+ remaininghdr = STATIC_CAST(TObexHeaderMask, ~iSendHeaders & iValidHeaders & iHeaderMask);
+ }
+ }
+
+ TInt dataspace = aPacket.RemainingInsertSpace() - KObexHeaderHILongSize;
+ TInt remainingdata = DataSize() - iSendBytes;
+ if(dataspace > 0 && remainingdata > 0 && !suppressDataHeader)
+ {// ...there's some room for data and we haven't sent it all, and we're allowed to add some
+ FLOG(_L("PrepareNextSendPacket - preparing some additional data\r\n"));
+ TPtr8 bufptr(NULL, 0);
+ if(remainingdata <= dataspace)
+ {
+ header.SetDeferred(TObexInternalHeader::EEndOfBody, &bufptr, remainingdata, remainingdata);
+ }
+ else
+ {
+ header.SetDeferred(TObexInternalHeader::EBody, &bufptr, 1, remainingdata - 1);
+ }
+ if(!aPacket.InsertData(header))
+ {
+ return(iSendProgress = EError);
+ }
+ else
+ {// Data header inserted, now load it up with data...
+ GetData(iSendBytes, bufptr);
+ if(bufptr.Length() < bufptr.MaxLength())
+ return(iSendProgress = EError);
+ iSendBytes += bufptr.Length();
+ remainingdata -= bufptr.Length();
+ }
+ }
+
+ if(!(remaininghdr || remainingdata > 0))
+ {// Check whether all(valid) headers and data will have been sent
+ iSendProgress = ELastPacket;
+
+ FLOG(_L("PrepareNextSendPacket - All headers packaged setting Final Bit\r\n"));
+ aPacket.SetFinal();
+ }
+ else if(aPacket.RemainingInsertSpace() == startspace)
+ {
+ // There are pending header or data but we inserted nothing!
+ // Some header isn't fitting into the packets provided.
+ FLOG(_L("PrepareNextSendPacket - nothing was actually inserted\r\n"));
+ iSendProgress = EError;
+ }
+
+ return(iSendProgress);
+ }
+
+/**
+Prepare the object for receiving into.
+@internalComponent
+*/
+TInt CObexBaseObject::InitReceive()
+ {
+ FLOG(_L("CObexBaseObject::InitReceive\r\n"));
+
+ // Always clear the object out before allowing it to receive anything
+ Reset();
+ iRecvBytes = 0;
+ iRecvProgress = EContinue;
+ return(KErrNone);
+ }
+
+/**
+Parse the passed packet, consuming headers into this object as appropriate.
+The returned progress can not be relied upon to indicate completion, because
+that is actually signalled at a diferent level, depending on the source of
+the packet(final bit or server complete response). Returning EComplete
+simply indicates that all of the object body has been received.
+
+@param aPacket The packet to extract the headers from
+
+@return The progress of header extraction
+@internalComponent
+*/
+CObexBaseObject::TProgress CObexBaseObject::ParseNextReceivePacket(CObexPacket &aPacket)
+ {
+ iLastError = ERespInternalError;
+ FLOG(_L("CObexBaseObject::ParseNextReceivePacket\r\n"));
+
+ if(iRecvProgress != EContinue && iRecvProgress != EComplete)
+ {
+ FLOG(_L("CObexBaseObject::ParseNextReceivePacket Error!!! Exiting\r\n"));
+ return(iSendProgress);
+ }
+ TObexInternalHeader header;
+
+ while(aPacket.ExtractData(header))
+ {
+ switch(header.HI())
+ {
+ case TObexInternalHeader::EConnectionID:
+ {
+ if ( iHeaderMask & KObexHdrConnectionID )
+ {
+ FLOG(_L("ParseNextReceivePacket extracting CONNECTIONID\r\n"));
+
+ iValidHeaders &= ~KObexHdrConnectionID;
+
+ TRAPD(err, SetConnectionIdL(header.HVInt()));
+
+ if (err)
+ {
+ return EError;
+ }
+ }
+ }
+ break;
+ case TObexInternalHeader::EAppParam:
+ {
+ if ( iHeaderMask & KObexHdrAppParam )
+ {
+ FLOG(_L("ParseNextReceivePacket extracting APPPARAM\r\n"));
+ iValidHeaders &= ~KObexHdrAppParam;
+
+
+ TPtrC8 src(header.HVByteSeq(), header.HVSize());
+ TRAPD(err, SetAppParamL(src));
+ if (err)
+ {
+ return EError;
+ }
+
+ iValidHeaders |= KObexHdrAppParam;
+ }
+ }
+ break;
+ case TObexInternalHeader::EHttp:
+ {
+ FLOG(_L("ParseNextReceivePacket extracting Http\r\n"));
+
+ TPtrC8 src(header.HVByteSeq(), header.HVSize());
+
+ TRAPD(err, AddHttpL(src));
+
+ if (err)
+ {
+ return EError;
+ }
+ }
+ break;
+ case TObexInternalHeader::EName:
+ {
+ if(iHeaderMask & KObexHdrName)
+ {
+ FLOG(_L("ParseNextReceivePacket Extracting NAME"));
+ iValidHeaders &= ~KObexHdrName;
+
+ HBufC* newHeader = HBufC::New(header.HVSize());
+ if (!newHeader)
+ {
+ return EError;
+ }
+ //else
+ TPtr ptr(newHeader->Des());
+
+ TInt err = KErrNone;
+
+ if(header.GetHVText(ptr) == KErrNone)
+ {
+ TRAP(err, SetNameL(*newHeader));
+ }
+ delete newHeader;
+ newHeader = NULL;
+
+ if (err)
+ {
+ return EError;
+ }
+ }
+
+ }
+ break;
+ case TObexInternalHeader::EType:
+ {
+ if(iHeaderMask & KObexHdrType)
+ {
+ FLOG(_L("ParseNextReceivePacket extracting TYPE\r\n"));
+ iValidHeaders &= ~KObexHdrType;
+
+ TPtrC8 src(header.HVByteSeq(), header.HVSize());
+ // use SetTypeL(), to ensure null terms are handled correctly
+ TRAPD(err, SetTypeL(src));
+ if (err)
+ {
+ return EError;
+ }
+
+ FLOG(_L("ParseNextReceivePacket extracting TYPE\r\n"));
+ }
+ }
+ break;
+ case TObexInternalHeader::ELength:
+ {
+ if(iHeaderMask & KObexHdrLength)
+ {
+ FLOG(_L("ParseNextReceivePacket extracting LENGTH\r\n"));
+ TRAPD(err, SetLengthL(header.HVInt()));
+
+ if (err)
+ {
+ return EError;
+ }
+
+ iValidHeaders |= KObexHdrLength;
+ }
+ }
+ break;
+ case TObexInternalHeader::ETime:// Time is ISO 8601 format byte sequence.
+ {
+ if(iHeaderMask & KObexHdrTime)
+ {
+ FLOG(_L("ParseNextReceivePacket extracting TIME in ISO 8601 format\r\n"));
+ TInt err = KErrGeneral;
+ TTime time;
+
+ // Use Win2k's incorrect TIME format header to calculate the size required.
+ // 2k inserts incorrect padding and uses Unicode format. Allow a little extra
+ // just in case. (Currently this should be 48 bytes)
+ static const TInt KMaxTIMESize = sizeof("yyyy.mm.ddThh:mm:ssZ") * 2 + 6;
+ TBuf<KMaxTIMESize> timebuf;
+
+ if(header.GetHVText(timebuf) == KErrNone && timebuf.LocateF('t') >= 0)
+ {
+ // Win2k sends an invalid TIME header, inserting unicode into a ByteSeq
+ // header, and inserting . and : characters between fields. So copy char
+ // by char, ignoring invalid characters.
+ TBuf8<16> narrowTime;
+#ifdef _DEBUG
+ TBool changed = EFalse;
+#endif
+ for (TInt copyByte = 0; copyByte <= timebuf.Length()-1; copyByte++)
+ {
+ TChar chr(timebuf[copyByte]);
+ if (chr && (chr != 0x2e /* . */) && (chr != 0x3a /* : */))
+ {
+ if (narrowTime.Length() < narrowTime.MaxLength())
+ {
+ narrowTime.Append(chr);
+ }
+ }
+#ifdef _DEBUG
+ else
+ {
+ changed = ETrue;
+ }
+#endif
+ }
+
+ // As we've mangled the header, output a log entry just in case...
+ FTRACE(if (changed) FLOG(_L(" - Windows non-compliant time header detected and converted")));
+
+ TRAP(err, SetTimeHeaderL(narrowTime));
+ }
+
+ if(err)
+ {
+ // Adding TIME header to object failed (out of memory?).
+ FLOG(_L("ParseNextReceivePacket extracting TIME in ISO 8601 format failed"));
+
+ // if adding TIME header to object failed, the header is ignored and the packet accepted
+ iValidHeaders &= ~KObexHdrTime;
+ }
+ else
+ {
+ // Adding TIME header succeeded, make a note.
+ iValidHeaders |= KObexHdrTime;
+ }
+ }
+ }
+ break;
+ case KFourByteTimeHeaderAddress : // Time is no. of secs since 1/1/1970
+ if (iHeaderMask & KObexHdrTime)
+ {
+ FLOG(_L("ParseNextReceivePacket extracting TIME in secs since 1/1/1970"));
+ TTimeIntervalSeconds secs = header.HVInt();
+ TRAPD(err, SetTimeL(TTime(TDateTime(1970, EJanuary, 0, 0, 0, 0, 0)) + secs));
+
+ if(err)
+ {
+ return EError;
+ }
+
+ iValidHeaders |= KObexHdrTime;
+ }
+ break;
+ case TObexInternalHeader::EDescription:
+ {
+ if(iHeaderMask & KObexHdrDescription)
+ {
+ FLOG(_L("ParseNextReceivePacket extracting DESCRIPTION\r\n"));
+ iValidHeaders &= ~KObexHdrDescription;
+
+ HBufC* newHeader = HBufC::New(header.HVSize());
+ if (!newHeader)
+ {
+ return EError;
+ }
+ //else
+ TPtr ptr(newHeader->Des());
+
+ TInt err = KErrNone;
+
+ if(header.GetHVText(ptr) == KErrNone)
+ {
+ TRAP(err, SetDescriptionL(*newHeader));
+ }
+ delete newHeader;
+ newHeader = NULL;
+
+ if (err)
+ {
+ return EError;
+ }
+ }
+ }
+ break;
+ case TObexInternalHeader::ECount:
+ {
+ if(iHeaderMask & KObexHdrCount)
+ {
+ FLOG(_L("ParseNextReceivePacket extracting Count\r\n"));
+
+ CObexHeader* newHeader = NULL;
+ TRAPD( err, newHeader = CObexHeader::NewL());
+ if (err)
+ {
+ return EError;
+ }
+ newHeader->SetFourByte(TObexInternalHeader::ECount, header.HVInt());
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ err = iHeaderSet->AddHeader(newHeader);
+ if (err)
+ {
+ delete newHeader;
+ newHeader = NULL;
+ return EError;
+ }
+ iValidHeaders |= KObexHdrCount;
+ }
+ }
+ break;
+ case TObexInternalHeader::ETarget:
+ {
+ if(iHeaderMask & KObexHdrTarget)
+ {
+ FLOG(_L("ParseNextReceivePacket extracting TARGET\r\n"));
+ iValidHeaders &= ~KObexHdrTarget;
+
+ TPtrC8 src(header.HVByteSeq(), header.HVSize());
+ TRAPD(err, SetTargetL(src));
+ if (err)
+ {
+ return EError;
+ }
+ }
+ }
+ break;
+ case TObexInternalHeader::ECreatorID:
+ {
+ if(iHeaderMask & KObexHdrCreatorID)
+ {
+ FLOG(_L("ParseNextReceivePacket Extracting CreatorID header"));
+
+ CObexHeader* fourByteHeader = NULL;
+ TRAPD( err, fourByteHeader = CObexHeader::NewL());
+ if (err)
+ {
+ return EError;
+ }
+ fourByteHeader->SetFourByte(TObexInternalHeader::ECreatorID, header.HVInt());
+ //Transfer ownership of pointer to CObexHeaderSet
+ err = iHeaderSet->AddHeader(fourByteHeader);
+ if (err)
+ {
+ delete fourByteHeader;
+ fourByteHeader = NULL;
+ return EError;
+ }
+ iValidHeaders |= KObexHdrCreatorID;
+ }
+ }
+ break;
+ case TObexInternalHeader::EWanUUID:
+ {
+ if(iHeaderMask & KObexHdrWanUUID)
+ {
+ FLOG(_L("ParseNextReceivePacket Extracting WanUUID header"));
+ TPtrC8 src(header.HVByteSeq(), header.HVSize());
+
+ CObexHeader* byteseqHeader = NULL;
+
+ byteseqHeader = IrOBEXHeaderUtil::CreateAndSetByteSeqHeader(TObexInternalHeader::EWanUUID, src);
+ if (!byteseqHeader)
+ {
+ return EError;
+ }
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ TInt err = iHeaderSet->AddHeader(byteseqHeader);
+ if (err)
+ {
+ delete byteseqHeader;
+ byteseqHeader = NULL;
+ return EError;
+ }
+
+ iValidHeaders |= KObexHdrWanUUID;
+ }
+ }
+ break;
+ case TObexInternalHeader::EObjectClass:
+ {
+ if(iHeaderMask & KObexHdrObjectClass)
+ {
+ FLOG(_L("ParseNextReceivePacket Extracting WanUUID header"));
+ TPtrC8 src(header.HVByteSeq(), header.HVSize());
+
+ CObexHeader* byteseqHeader = NULL;
+
+ byteseqHeader = IrOBEXHeaderUtil::CreateAndSetByteSeqHeader(TObexInternalHeader::EObjectClass, src);
+ if (!byteseqHeader)
+ {
+ return EError;
+ }
+
+ //Transfer ownership of pointer to CObexHeaderSet
+ TInt err = iHeaderSet->AddHeader(byteseqHeader);
+ if (err)
+ {
+ delete byteseqHeader;
+ byteseqHeader = NULL;
+ return EError;
+ }
+
+ iValidHeaders |= KObexHdrObjectClass;
+ }
+ }
+ break;
+ case TObexInternalHeader::EBody:
+ iValidHeaders |= KObexHdrBody;
+ //Fall-through
+ case TObexInternalHeader::EEndOfBody:
+ {
+ FLOG(_L("ParseNextReceivePacket extracting BODY\r\n"));
+ TPtr8 ptr(header.HVByteSeq(), header.HVSize(), header.HVSize());
+
+ if(header.HI() == TObexInternalHeader::EEndOfBody)
+ {// Body finished, there _could_ still be more headers, however...
+ iValidHeaders |= KObexHdrEndOfBody;
+ FLOG(_L("ParseNextReceivePacket extracting ENDOFBODY\r\n"));
+ iRecvProgress = EComplete;
+ }
+
+ NewData(iRecvBytes, ptr);
+ if(ptr.Length() < header.HVSize())
+ {
+ return(iRecvProgress = EError);
+ }
+ iRecvBytes += ptr.Length();
+ }
+ break;
+ case TObexInternalHeader::EAuthChallenge:
+ {
+ iLastError = ERespUnauthorized;
+ return EError;
+ }
+ default:
+ {
+ // Non Standard header received so check for user defined header
+ // NB. All user defined headers are in range 0x30..0x3F
+
+ if ((iHeaderMask & KObexHdrUserDefined) &&
+ ((header.HI() & 0x30) != 0))
+ {
+ FLOG(_L("ParseNextReceivePacket Extracting User Defined Unicode header"));
+ if( IrOBEXHeaderUtil::ParseHeader(header, *iHeaderSet) == KErrNone)
+ {
+ iValidHeaders |= KObexHdrUserDefined;
+ }
+ else
+ {
+ return EError;
+ }
+ }
+
+ } // End of default
+
+ } // End of header type switch
+ } // End of while
+
+ return(iRecvProgress);
+ }
+
+/**
+Returns the Obex Error response code from the last call to CObexBaseObject::ParseNextReceivePacket
+
+@return The Obex Response code
+@internalComponent
+*/
+
+TObexResponse CObexBaseObject::GetLastError() const
+ {
+ return iLastError;
+ }
+
+/**
+Sets the header mask. aHeaderMask is built up by bit-wise ‘or’ing any of
+the KObexHdr... constants.
+For example, if it is set to KObexHdrName | KObexHdrLength, only
+these two headers will be specified in transfer operations with the remote
+machine, even if there are other valid attributes which could be used. In
+effect, this mask is bit-wise ‘and’ed with the "valid headers" mask when
+determining which headers are valid for the purposes of transfers.
+
+@param aHeaderMask: the header mask to be set
+
+@publishedAll
+@released
+**/
+EXPORT_C void CObexBaseObject::SetHeaderMask(const TObexHeaderMask aHeaderMask)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHeaderMask=aHeaderMask;
+ }
+
+/**
+Returns the number of bytes of the body of the object transferred so far
+while sending this object.
+
+@return The number of bytes sent
+
+@publishedAll
+@released
+**/
+EXPORT_C TInt CObexBaseObject::BytesSent()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return(iSendBytes);
+ }
+
+/**
+Returns the number of bytes of the body of the object transferred while
+receiving an object.
+
+@return The number of bytes received
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexBaseObject::BytesReceived()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return(iRecvBytes);
+ }
+
+/**
+Returns the currently set header mask. This defaults to 0xFF (i.e. allow
+everything) when Reset () or InitFromFileL is called. This does not specify
+which headers currently contain valid data--merely which headers will be
+transferred if they do contain valid data.
+
+@return The currently set header mask
+@publishedAll
+@released
+*/
+EXPORT_C TObexHeaderMask CObexBaseObject::HeaderMask()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iHeaderMask;
+ }
+
+/**
+Returns the current valid header mask. This allows inspection of the current
+set of valid headers, particularly useful for determining whether a put
+object contained a body header (important for deleting files as part of file
+transfer).
+
+@return The current valid header mask
+@publishedAll
+@released
+*/
+EXPORT_C TObexHeaderMask CObexBaseObject::ValidHeaders()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iValidHeaders;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexobjects.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,1271 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <obex.h>
+#include <obexpanics.h>
+#include "logger.h"
+#include "OBEXUTIL.H"
+#include "obexasyncfilewriter.h"
+#include "obexsyncfilewriter.h"
+#include "obexfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/** Creates a new CObexFileObject object.
+Static file object factory. returns a new CObexFileObject, set up to use a
+temporary file to store received data into "on the fly". If used for
+sourcing an object to send a "NULL" object(body length 0) will be sent.
+@return Instance of CObexFileObject
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexFileObject* CObexFileObject::NewL()
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexFileObject* self = new(ELeave) CObexFileObject;
+ CleanupStack::PushL(self);
+ self->ConstructL(TPtrC(NULL, 0));
+ CleanupStack::Pop();
+ return(self);
+ }
+
+/** Creates a new CObexFileObject object.
+Static file object factory. returns a new CObexFileObject, set up to use
+aDataFile as its data file, or will create a temp file if aDataFile is not
+a valid file name. If used for sourcing an object to send, and no valid data
+file is set, a "NULL" object(body length 0) will be sent.
+@param aDataFile Filename to configure this object to use
+@return Instance of CObexFileObject
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexFileObject* CObexFileObject::NewL(const TDesC &aDataFile)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexFileObject* self = new(ELeave) CObexFileObject;
+ CleanupStack::PushL(self);
+ self->ConstructL(aDataFile);
+ CleanupStack::Pop();
+ return(self);
+ }
+
+/** Destructor.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexFileObject::~CObexFileObject()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ ResetData();
+ iFs.Close();
+ }
+
+/**
+Sets the name of a file which holds the data to be used as the objects body.
+Leaves if the file does not exist, or can not be opened for writing.
+
+@param aDesc Filename to configure this object to use
+*/
+void CObexFileObject::SetDataFileL(const TDesC& aDesc)// does this need to be exported????
+ {
+ ResetData();
+ if(aDesc.Length() == 0)
+ return;
+ TInt err = iDataFile.SetNoWild(aDesc, NULL, NULL);
+ if(err == KErrNone) //try and open for read/write
+ err = iFile.Open(iFs, iDataFile.FullName(), EFileWrite | EFileShareExclusive);
+ if(err != KErrNone)
+ { //can't open it for write so open it for read
+ err = iFile.Open(iFs, iDataFile.FullName(), EFileRead | EFileShareReadersOnly);
+ if(err != KErrNone)
+ {
+ iDataFile.SetNoWild(KNullDesC, NULL, NULL);
+ iFile.Close(); // Manually close file
+ User::Leave(err);
+ }
+ }
+ }
+
+/**
+Get the name of the file representing the object body.
+
+@return the full path and name of the file representing the object body.
+ Null descriptor if no valid data file has been set, or if Reset()
+ has been called on the object since a file was last set.
+*/
+const TDesC& CObexFileObject::DataFile()
+ {
+ return iDataFile.FullName();
+ }
+
+TInt CObexFileObject::RenameFile(const TDesC& aDesC)
+ {
+ iFile.SetAtt(0,KEntryAttHidden);// - dont check return code - if it fails it fails
+ return(iFile.Rename(aDesC));
+ }
+
+void CObexFileObject::SetTempFilePath(const TDesC& aPath)
+ {
+ iTempFilePath = aPath;
+ }
+
+void CObexFileObject::QueryTempFilePath(TDes& aPath)
+ {
+ aPath = iTempFilePath;
+ }
+
+/**
+Constructs this object.
+
+@param aDataFile The file to use for the object's data part.
+*/
+void CObexFileObject::ConstructL(const TDesC &aDataFile)
+ {
+ CreateHeaderStorageDataL();
+ LEAVEIFERRORL(iFs.Connect());
+ SetDataFileL(aDataFile);
+ iTempFilePath = KNullDesC;
+ }
+
+/** Initialises this object from the specified file.
+
+The function attempts to set attribute values for the object as follows:
+
+Length:set to the length of the file
+
+Name:taken from the name portion of the path in aFile
+
+Time:taken from the modification time of the file
+
+Type:set appropriately if the file extension is .vcf (VCard), .vcs (Vcalendar),
+or .txt.
+
+@param aFile Body data file
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexFileObject::InitFromFileL(const TDesC& aFile)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ Reset();
+ SetDataFileL(aFile);
+
+
+ SetNameL(iDataFile.NameAndExt());
+ GuessTypeFromExtL(iDataFile.Ext());
+
+ TInt length;
+ if(iFile.Size(length) == KErrNone)
+ {
+ SetLengthL(length);
+ }
+
+ TTime time;
+ if(iFile.Modified(time) == KErrNone)
+ {
+ SetUtcTimeL(time);
+ }
+ }
+
+
+/**
+Virtual pure function form the base object. Tries to fill aDes with data
+starting from aPos byte offset. returns null descriptor if no data file is
+set.
+@param aPos Position (reliative to start of object) to start extracting data from
+@param aDes Descriptor to fill
+*/
+void CObexFileObject::GetData(TInt aPos, TDes8& aDes)
+ {
+ if(iDataFile.NameOrExtPresent() && iFile.Read(aPos, aDes) == KErrNone)
+ return;
+ aDes.SetLength(0);
+ }
+
+/**
+Virtual pure function overload. inserts aDes into the data file at location
+aPos
+@param aPos Position (reliative to start of object) to start inserting data from
+@param aDes Descriptor to insert
+*/
+void CObexFileObject::NewData(TInt aPos, TDes8& aDes)
+ {
+// iTempFilePath.SetLength(0);
+ if(!iDataFile.NameOrExtPresent())
+ {
+ ResetData();
+ TFileName fname;
+ TInt err = iFile.Temp(iFs, iTempFilePath, fname, EFileWrite | EFileShareExclusive);
+ if(err == KErrNone)
+ err = iFs.Parse(fname, iDataFile.Path(), iDataFile);
+ if(err != KErrNone)
+ {
+ ResetData();
+ iFs.Delete(fname);
+ aDes.SetLength(0);
+ return;
+ }
+ iFile.SetAtt(KEntryAttHidden,0);// dont check return code - if it fails it fails
+ }
+ if(iFile.Write(aPos, aDes) != KErrNone)
+ aDes.SetLength(0);
+ }
+
+/**
+@return number of bytes in the data file (0 if no file is set)
+*/
+TInt CObexFileObject::DataSize()
+ {
+ if(!iDataFile.NameOrExtPresent())
+ return(0);
+ TInt size = 0;
+ iFile.Size(size);
+ return(size);
+ }
+
+/**
+Set object back to a null file.
+*/
+void CObexFileObject::ResetData()
+ {
+ iFile.Close();
+ iDataFile.Set(KNullDesC, NULL, NULL);
+ }
+
+//
+// class CObexBufObject
+//
+
+/**
+Allocates and constructs a new OBEX dynamic buffer object, specifying a buffer.
+
+@param aDataBuf The buffer for the body of the object. This must be set either
+ by this constructor or by calling SetDataBufL() before using the object.
+@return New OBEX dynamic buffer object
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexBufObject* CObexBufObject::NewL(CBufBase* aDataBuf)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexBufObject* self = new(ELeave) CObexBufObject;
+ CleanupStack::PushL(self);
+ self->ConstructL(aDataBuf);
+ CleanupStack::Pop();
+ return(self);
+ }
+
+/** Destructor.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexBufObject::~CObexBufObject()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ delete iWriter;
+
+ CloseDataFile();
+ CloseFileServer();
+
+ delete iFilename;
+
+ delete iDoubleBuf;
+ }
+
+/** Writes contents of object to a file
+@param aFileName Target file
+@return a Symbian OS error code if file write fails.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexBufObject::WriteToFile(const TPtrC& aFileName)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ TInt ret = KErrNone;
+ TRAP(ret, CopyFileL(aFileName));
+ return ret;
+ }
+
+
+NONSHARABLE_CLASS(TFileDetails)
+ {
+public:
+ TFileDetails(RFile& aFile, RFs& aFs, const TDesC& aFilename);
+ inline RFile* File();
+ inline RFs* FileServ();
+ inline const TDesC* Filename();
+
+private:
+ RFile* iFile;
+ RFs* iFileServ;
+ const TDesC* iFilename;
+ };
+
+
+TFileDetails::TFileDetails(RFile& aFile, RFs& aFs, const TDesC& aFilename)
+ : iFile(&aFile), iFileServ(&aFs), iFilename(&aFilename)
+ {}
+
+RFile* TFileDetails::File()
+ { return iFile; }
+
+RFs* TFileDetails::FileServ()
+ { return iFileServ; }
+
+const TDesC* TFileDetails::Filename()
+ { return iFilename; }
+
+
+void DoCloseDeleteFile(TAny* aAny)
+// This function does not check for errors. Since we're closing down, not much
+// that we could do!
+ {
+ TFileDetails* fileDetails = reinterpret_cast<TFileDetails*>(aAny);
+ if (fileDetails)
+ {
+ fileDetails->File()->Close();
+ fileDetails->FileServ()->Delete(*(fileDetails->Filename()));
+ }
+ }
+
+
+// Writes object data to specified file. Called from WriteToFile, exists to simplify
+// error handling as this function can leave. Leaves are trapped in the caller.
+void CObexBufObject::CopyFileL(const TDesC& aFilename)
+ {
+ // Open persistent connection to fileserver if don't currently
+ // have one
+ LEAVEIFERRORL(OpenFileServer());
+
+ RFile writeFile;
+ LEAVEIFERRORL(writeFile.Create(*iFileServ, aFilename, EFileWrite | EFileShareExclusive));
+
+ TFileDetails writeFileDetails(writeFile, *iFileServ, aFilename);
+ CleanupStack::PushL(TCleanupItem(DoCloseDeleteFile, &writeFileDetails));
+
+ // Now have three situations to worry about. May have a file, in which
+ // case we need to copy data to the target file. If there's a buffer for
+ // writes to this file, need to flush it first.
+ // Then may be using a memory buffer, in which case we just need to save
+ // the data.
+ if (iFile)
+ {
+ if (iBuf)
+ {
+ LEAVEIFERRORL(WriteBufferToFile(ETrue));
+ iBufOffset += iBuffered;
+ }
+
+ TInt dataSize = DataSize();
+ TInt bufSize = Min<TInt>(dataSize, 1024);
+ // Expands to TInt bufSize = (dataSize > 1024) ? 1024 : dataSize;
+ HBufC8* buffer = HBufC8::NewMaxLC(bufSize);
+
+ TInt written = 0;
+ TPtr8 ptr = buffer->Des();
+
+ while (written < dataSize)
+ {
+ LEAVEIFERRORL(iFile->Read(written, ptr));
+ LEAVEIFERRORL(writeFile.Write(written, ptr));
+ written += ptr.Length();
+ }
+
+ CleanupStack::PopAndDestroy(buffer);
+ }
+ else
+ {
+ TInt segmentSize = iBuf->Ptr(0).Size();
+ TInt written = 0;
+ while (written < BytesReceived())
+ {
+ LEAVEIFERRORL(writeFile.Write(written, iBuf->Ptr(written)));
+ written += segmentSize;
+ }
+ }
+
+ CleanupStack::Pop(); // file
+ writeFile.Close();
+ }
+
+
+/**
+Build a TObexBufferingDetails object.
+@param aBuffer The CBufBase derived object for Obex to use as a data store.
+ This object will be resized as appropriate to hold the entire Obex object.
+
+@publishedAll
+@released
+*/
+EXPORT_C TObexBufferingDetails::TObexBufferingDetails(CBufBase& aBuffer)
+ : iVersion(EBasicBuffer), iBuffer(&aBuffer)
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+
+/**
+Build a TObexBufferingDetails object, setting the version appropriately.
+@param aVersion Version number to insert.
+@param aBuffer The buffer object to use.
+
+@internalComponent
+*/
+TObexBufferingDetails::TObexBufferingDetails(TVersion aVersion, CBufBase* aBuffer)
+ : iVersion(aVersion), iBuffer(aBuffer)
+ {
+ __ASSERT_DEBUG(aVersion < ELastVersion, IrOBEXUtil::Fault(EBadBufferDetailsVersion));
+ }
+
+/**
+Return the version of this object
+@internalComponent
+*/
+TObexBufferingDetails::TVersion TObexBufferingDetails::Version()
+ {
+ return iVersion;
+ }
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+CBufBase* TObexBufferingDetails::Buffer()
+ {
+ return iBuffer;
+ }
+
+
+/**
+Build a variant of TObexBufferingDetails which instructs the CObexBufObject
+to use a file as the only data store. This is a special case option provided
+to cater for the MObexServerNotify interface which requires the use of
+CObexBufObject objects. It is generally better to use a buffered variant.
+If the file cannot be opened for read/write access it will be opened in read
+only mode. In this situation, attempts to store data in this object will cause
+an Obex error to be signalled in response to the Obex packet which carried the
+body data.
+
+@param aFilename The file to link the object to.
+
+@publishedAll
+@released
+*/
+EXPORT_C TObexPureFileBuffer::TObexPureFileBuffer(const TPtrC& aFilename)
+ : TObexBufferingDetails(EPureFile, NULL), iFilename(aFilename)
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+const TPtrC& TObexPureFileBuffer::Filename()
+ {
+ return iFilename;
+ }
+
+
+/**
+Build a variant of TObexBufferingDetails which instructs the CObexBufObject
+to use a file as the main data store, buffering writes to this in chunks.
+Writes are buffered into the supplied CBufBase derived object, which is not
+resized. Once it is full, the data contained is written to file.
+Double buffering can be specified by setting aBufferingStrategy appropriately.
+If the file cannot be opened for read/write access it will be opened in read
+only mode. In this situation, attempts to store data in this object will cause
+an Obex error to be signalled in response to the Obex packet which carried the
+body data.
+
+@param aBuffer The buffer to use as a temporary store. This is ignored when
+ reading from the file.
+@param aFilename The filename to use to permanently store the object.
+@param aBufferingStrategy Use double or single buffering.
+@publishedAll
+@released
+*/
+EXPORT_C TObexFilenameBackedBuffer::TObexFilenameBackedBuffer(CBufBase& aBuffer, const TPtrC& aFilename, CObexBufObject::TFileBuffering aBufferingStrategy)
+ : TObexBufferingDetails(EFilenameBackedBuffer, &aBuffer),
+ iFilename(aFilename),
+ iBufferingStrategy(aBufferingStrategy)
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+const TPtrC& TObexFilenameBackedBuffer::Filename()
+ {
+ return iFilename;
+ }
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+CObexBufObject::TFileBuffering TObexFilenameBackedBuffer::Strategy()
+ {
+ return iBufferingStrategy;
+ }
+
+
+/**
+Build a variant of TObexBufferingDetails which instructs the CObexBufObject
+to use a file as the main data store, buffering writes to this in chunks.
+Writes are buffered into the supplied CBufBase derived object, which is not
+resized. Once it is full, the data contained is written to file.
+Double buffering can be specified by setting aBufferingStrategy appropriately.
+If the file is opened in read only mode, attempts to store data in this object
+will cause an Obex error to be signalled in response to the Obex packet which
+body data.
+
+@param aBuffer The buffer to use as a temporary store. This is ignored when
+ reading from the file.
+@param aFile An RFile object pointing to the file, opened in an appropriate
+ access mode.Note, Obex is responsible for closing the file, and a panic will
+ result if an attempt is made to close the file from outside of Obex.
+@param aBufferingStrategy Use double or single buffering.
+@publishedAll
+@released
+*/
+EXPORT_C TObexRFileBackedBuffer::TObexRFileBackedBuffer(CBufBase& aBuffer, RFile aFile, CObexBufObject::TFileBuffering aBufferingStrategy)
+ : TObexBufferingDetails(ERFileBackedBuffer, &aBuffer),
+ iFile(aFile),
+ iBufferingStrategy(aBufferingStrategy)
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+RFile TObexRFileBackedBuffer::File()
+ {
+ return iFile;
+ }
+
+
+/**
+Basic getter.
+@internalComponent
+*/
+CObexBufObject::TFileBuffering TObexRFileBackedBuffer::Strategy()
+ {
+ return iBufferingStrategy;
+ }
+
+
+/**
+Set the data buffers as specified in the supplied TObexBufferingDetails object.
+@param aDetails The buffering techniques to use. This only has to persist
+ over the duration of the call to SetDataBufL, once this has returned it can
+ be allowed to go out of scope.
+
+@panic Obex ENullFileHandle TObexPanicCode::ENullFileHandle The RFile object does not point
+to a valid (open) file.
+@panic Obex EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.
+@panic Obex EInvalidBufferDetails TObexPanicCode::EInvalidBufferDetails An unknown TObexBufferingDetails
+object was supplied
+@panic Obex EInvalidBufferStrategy TObexPanicCode::EInvalidBufferStrategy An unknown TFileBuffering
+value was supplied.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(TObexBufferingDetails& aDetails)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ PrepareToSetBufferL();
+
+ iBuf = aDetails.Buffer();
+ if (iBuf)
+ {
+ iBufSegSize = iBuf->Ptr(0).Size();
+ }
+
+ TBool initFile = EFalse;
+ TBool initFileServer = EFalse;
+ TBool initFileWriter = EFalse;
+ TFileBuffering bufferingStrategy = ESingleBuffering;
+
+ switch (aDetails.Version())
+ {
+ case TObexBufferingDetails::EBasicBuffer:
+ {
+ // All required details already set.
+ break;
+ }
+
+ case TObexBufferingDetails::EPureFile:
+ {
+ TObexPureFileBuffer& detail = static_cast<TObexPureFileBuffer&>(aDetails);
+ iFilename = detail.Filename().AllocL();
+
+ initFileServer = ETrue;
+ initFile = ETrue;
+ break;
+ }
+
+ case TObexBufferingDetails::EFilenameBackedBuffer:
+ {
+ __ASSERT_ALWAYS(iBuf, IrOBEXUtil::Panic(ENullPointer));
+ __ASSERT_ALWAYS(iBuf->Size(), IrOBEXUtil::Panic(EEmptyBuffer));
+
+ TObexFilenameBackedBuffer& detail = static_cast<TObexFilenameBackedBuffer&>(aDetails);
+
+ iFilename = detail.Filename().AllocL();
+ bufferingStrategy = detail.Strategy();
+
+ initFileServer = ETrue;
+ initFile = ETrue;
+ initFileWriter = ETrue;
+ break;
+ }
+
+ case TObexBufferingDetails::ERFileBackedBuffer:
+ {
+ __ASSERT_ALWAYS(iBuf, IrOBEXUtil::Panic(ENullPointer));
+ __ASSERT_ALWAYS(iBuf->Size(), IrOBEXUtil::Panic(EEmptyBuffer));
+
+ TObexRFileBackedBuffer& detail = static_cast<TObexRFileBackedBuffer&>(aDetails);
+ __ASSERT_ALWAYS(detail.File().SubSessionHandle(), IrOBEXUtil::Panic(ENullFileHandle));
+
+ iFile = new(ELeave) RFile(detail.File());
+ bufferingStrategy = detail.Strategy();
+
+ initFileServer = ETrue;
+ initFileWriter = ETrue;
+ break;
+ }
+
+ default:
+ {
+ IrOBEXUtil::Panic(EInvalidBufferDetails);
+ }
+ }
+
+ if (initFileServer)
+ {
+ LEAVEIFERRORL(OpenFileServer());
+ }
+
+ if (initFile)
+ {
+ LEAVEIFERRORL(OpenDataFile(*iFilename));
+ }
+
+ if (initFileWriter)
+ {
+ switch (bufferingStrategy)
+ {
+ case ESingleBuffering:
+ iWriter = CObexSyncFileWriter::NewL(*iFile);
+ break;
+
+ case EDoubleBuffering:
+ iWriter = CObexAsyncFileWriter::NewL(*iFile);
+ iDoubleBuf = CBufFlat::NewL(iBufSegSize);
+ iDoubleBuf->ResizeL(iBufSegSize);
+ break;
+
+ default:
+ IrOBEXUtil::Panic(EInvalidBufferStrategy);
+ break;
+ }
+ }
+ }
+
+
+/**
+Delete all owned resources in preparation for getting new settings.
+@internalComponent
+*/
+void CObexBufObject::PrepareToSetBufferL()
+ {
+ // Flush file buffer, if any.
+ if (iFile && iBuf)
+ {
+ LEAVEIFERRORL(WriteBufferToFile(ETrue));
+ iBufOffset = 0;
+ }
+
+ // The writer must be deleted at the same time as or before the file
+ // otherwise the writer will have an invalid file handle
+ delete iWriter;
+ iWriter = NULL;
+
+ CloseDataFile();
+
+ delete iFilename;
+ iFilename = NULL;
+
+ delete iDoubleBuf;
+ iDoubleBuf = NULL;
+
+ iBuf = NULL;
+ }
+
+
+/**
+Sets a buffer to use the object body data.
+
+Note that the function can leave.
+
+@param aDataBuf The buffer for the body of the object.
+@panic Obex ENullPointer TObexPanicCode::ENullPointer A NULL value was supplied for the
+data buffer.
+
+@publishedAll
+@deprecated
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(CBufBase* aDataBuf)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_ALWAYS(aDataBuf, IrOBEXUtil::Panic(ENullPointer));
+ TObexBufferingDetails details(*aDataBuf);
+ SetDataBufL(details);
+ }
+
+
+/**
+Set object to use aFilename as its data area. Leaves if unable to open file.
+
+@param aFilename The filename to link the object to.
+
+@publishedAll
+@deprecated
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(const TPtrC& aFilename)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ TObexPureFileBuffer details(aFilename);
+ SetDataBufL(details);
+ }
+
+
+/**
+Set object to use aFilename as its data area. Leaves if unable to open file.
+Buffers data into aDataBuf before writing to file. Will not grow the memory buffer,
+so user can tune buffering behaviour when calling function.
+
+@param aFilename The filename to link the object to.
+@param aDataBuf The buffer for the body of the object.
+@panic Obex ENullPointer TObexPanicCode::ENullPointer A NULL value was supplied for the
+data buffer.
+@panic Obex EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.
+
+@publishedAll
+@deprecated
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(const TPtrC& aFilename, CBufBase* aDataBuf)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_ALWAYS(aDataBuf, IrOBEXUtil::Panic(ENullPointer));
+ TObexFilenameBackedBuffer details(*aDataBuf, aFilename, ESingleBuffering);
+ SetDataBufL(details);
+ }
+
+
+/**
+Set object to write to file, using buffering and the specified
+buffering strategy. Note the size of the buffer passed to this
+function will determine the size of the second buffer if double
+buffering is employed.
+
+@param aFilename The file to link the object to.
+@param aDataBuf A buffer to use.
+@param aBufferingStrategy The buffering strategy to employ.
+@panic Obex EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.
+@panic Obex EInvalidBufferStrategy TObexPanicCode::EInvalidBufferStrategy An unknown TFileBuffering
+
+@publishedAll
+@deprecated
+*/
+EXPORT_C void CObexBufObject::SetDataBufL(const TPtrC& aFilename, CBufBase& aDataBuf, const TFileBuffering aBufferingStrategy)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ TObexFilenameBackedBuffer details(aDataBuf, aFilename, aBufferingStrategy);
+ SetDataBufL(details);
+ }
+
+
+/**
+Gets the buffer.
+
+@return The buffer for the body of the object.
+
+@publishedAll
+@released
+*/
+EXPORT_C CBufBase* CObexBufObject::DataBuf()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return(iBuf);
+ }
+
+
+/**
+Returns a pointer to the HBuf holding the filename this object is using.
+May return a null pointer.
+@return iFilename The file name.
+@internalComponent
+*/
+HBufC* CObexBufObject::FileName()
+ {
+ return(iFilename);
+ }
+
+
+CObexBufObject::CObexBufObject()
+ {
+ }
+
+void CObexBufObject::ConstructL(CBufBase* aDataBuf)
+ {
+ CreateHeaderStorageDataL();
+ if (aDataBuf)
+ SetDataBufL(aDataBuf);
+ }
+
+/**
+Reads aDes (up to MaxLength) from aPos offset into the buffer
+
+@param aPos The offset into the buffer to read from
+@param aDes The descriptor to read from
+*/
+void CObexBufObject::GetData(TInt aPos, TDes8& aDes)
+ {
+ __ASSERT_ALWAYS((iBuf || iFile), IrOBEXUtil::Panic(ENullPointer));
+
+ if (iFile)
+ {
+ GetFileData(aPos, aDes);
+ }
+ else
+ {
+ iBuf->Read(aPos, aDes);
+ }
+ }
+
+void CObexBufObject::GetFileData(TInt aPos, TDes8& aDes)
+ {
+ if(iFile->Read(aPos, aDes) == KErrNone)
+ return;
+ aDes.SetLength(0);
+ }
+
+/**
+Writes aDes into the buffer at aPos offset, growing the buffer if necessary
+*/
+void CObexBufObject::NewData(TInt aPos, TDes8& aDes)
+ {
+ // Three possible cases here. Can either be receiving into a memory
+ // buffer (old behaviour), receiving directly into a file or buffering
+ // file writes into a fixed size buffer.
+
+ // Should always have at least one of iBuf or iFile set.
+ __ASSERT_ALWAYS((iBuf || iFile), IrOBEXUtil::Panic(ENullPointer));
+
+ if (iFile)
+ {
+ TInt err = NewFileData(aPos, aDes);
+ if (err != KErrNone)
+ {
+ LOG1(_L8("Couldn't write data to file (error %d)"), err);
+ aDes.SetLength(0);
+ return;
+ }
+ }
+ else
+ {
+ if(iBuf->Size() < aPos + aDes.Size())
+ {// Buffer needs to grow. Try to guess how big it needs to be.
+ TInt reqsz = aPos + aDes.Size();
+ if((TInt)Length() > reqsz)
+ reqsz = Length();
+ TRAPD(err, iBuf->ResizeL(reqsz));
+ if(err != KErrNone)
+ {// OOM, probably.
+ LOG2(_L8("Couldn't resize buffer object to %d bytes (error %d)"),
+ reqsz, err);
+ iBuf->Compress();
+ aDes.SetLength(0);
+ return;
+ }
+ }
+ iBuf->Write(aPos, aDes);
+ }
+ }
+
+
+/**
+Write new data into a file
+
+We write data out to the file in chunks of iBufSegSize,
+the (segment) size of the buffer. A packet of data is
+passed to this method in aDes. aDes may or may not take
+us past the the end of the buffer. If it does, then we
+write out the buffer then continue filling it up with
+the rest of aDes. We repeat this until we have used up
+all of aDes. iBufOffset is the last write position in
+the file. remaining is the amount of data in aDes yet to
+be processed, written is the amount of data in aDes that
+has been processed. iBuffered is the amount of data in
+iBuf and spare is the amount of free space in the buffer.
+
+@code
+ aDes.Length()
+ <---------------------->
+ ------------------------------------------------------------------------
+| ... |xxxxxxxxxxxx|\\\\\\\\\\|//|*************| ... |
+| ... |xxxxxxxxxxxx|\\\\\\\\\\|//|*************| ... |
+ ------------------------------------------------------------------------
+0 ... iBufOffset aPos ... this.Length()
+
+ written remaining
+ <---------><----------->
+
+ iBuffered spare
+ <----------------------><------------------------>
+
+ iBufSegSize
+ <------------------------------------------------>
+
+ Key:
+ xxx = data already in buffer
+ \\\ = processed data from aDes, copied into iBuf
+ // = unprocessed data from aDes, not yet copied into iBuf
+ *** = free space in iBuf
+@endcode
+
+If there is more data remaining than there is spare space in
+the buffer, then the buffer is filled and written to disk and
+the remainer of the data is then used to continue filling the
+buffer.
+
+@param aPos The position at which aDes is to be written into the file.
+@param aDes The data to write to the file.
+@return Symbian OS error code
+*/
+TInt CObexBufObject::NewFileData(TInt aPos, TDes8& aDes)
+ {
+ // We have a memory buffer to (hopefully) speed file writes.
+ if (iBuf)
+ {
+ TInt err = KErrNone;
+
+ // If moving to earlier position in object, write out buffer
+ if (iBuffered && (aPos < iBufOffset))
+ {
+ err = WriteBufferToFile(EFalse);
+ if (err) return err;
+ }
+
+ TInt written = 0;
+ TInt remaining;
+
+ // Calculate the amount of data still to be processed and
+ // continue whilst there is still data to process
+ while ((remaining = (aDes.Length() - written)) > 0)
+ {
+ // Buffer full, write to file
+ if (iBuffered == iBufSegSize)
+ {
+ err = WriteBufferToFile(EFalse);
+ if (err) return err;
+ }
+
+ // Buffer empty, update buffer base
+ if (iBuffered == 0)
+ {
+ iBufOffset = aPos + written;
+ }
+
+ // Calculate the remaining space in the buffer (spare) and
+ // hence the amount of data we can process (length)
+ TInt spare = iBufSegSize - iBuffered;
+ TInt length = (spare > remaining) ? remaining : spare;
+
+ // Copy amount of data to be procesed (length) from the
+ // unprocessed portion of the packet (aDes.Right(remaining))
+ // into the buffer.
+ iBuf->Write(iBuffered, aDes.Right(remaining), length);
+
+ // Update variables to reflect newly processed data
+ written += length;
+ iBuffered += length;
+ }
+
+ // Is this the final packet?
+ const TBool finalPacket = (ValidHeaders() & KObexHdrEndOfBody);
+
+ // Flush buffer to file if we're done and there's data left
+ if (finalPacket && iBuffered)
+ {
+ err = WriteBufferToFile(ETrue);
+ iBufOffset = 0;
+
+ if (err) return err;
+ }
+ }
+ else
+ // Just write directly to the file
+ {
+ return iFile->Write(aPos, aDes);
+ }
+
+ return KErrNone;
+ }
+
+
+TInt CObexBufObject::DataSize()
+ {
+ __ASSERT_ALWAYS((iBuf || iFile), IrOBEXUtil::Panic(ENullPointer));
+ if (iFile)
+ {
+ // Flush file buffer, if any.
+ if (iBuf)
+ {
+ (void) WriteBufferToFile(ETrue);
+ }
+ // Get file size
+ TInt size;
+ iFile->Size(size);
+ return size;
+ }
+ else
+ {
+ return (iBuf->Size());
+ }
+ }
+
+void CObexBufObject::ResetData()
+ {
+ __ASSERT_ALWAYS((iBuf || iFile), IrOBEXUtil::Panic(ENullPointer));
+ if (iFile)
+ {
+ iFile->SetSize(0);
+ if (iBuf)
+ {
+ iBufOffset = 0;
+ iBuffered = 0;
+ }
+ }
+ else
+ {
+ iBuf->Reset();
+ }
+ }
+
+
+TInt CObexBufObject::OpenDataFile(const TDesC& aFilename)
+ {
+ TInt err = KErrNotReady;
+
+ if (!iFile)
+ {
+ iFile = new RFile;
+ if (!iFile) return KErrNoMemory;
+
+ //Try and open the file for read/write
+ err = iFile->Open(*iFileServ, aFilename, EFileWrite | EFileShareExclusive);
+ if (err != KErrNone)
+ {
+ //Try and open file for read only
+ err = iFile->Open(*iFileServ, aFilename, EFileRead | EFileShareReadersOnly);
+ if(err == KErrNotFound)
+ {
+ err = iFile->Create(*iFileServ, aFilename, EFileWrite | EFileShareExclusive);
+ }
+ }
+
+ if (err)
+ {
+ delete iFile;
+ iFile = 0;
+ }
+ }
+
+ return err;
+ }
+
+
+void CObexBufObject::CloseDataFile()
+ {
+ if (iFile)
+ {
+ iFile->Close();
+ delete iFile;
+ iFile = 0;
+ }
+ }
+
+TInt CObexBufObject::OpenFileServer()
+ {
+ TInt err = KErrNone;
+
+ if (!iFileServ)
+ {
+ iFileServ = new RFs;
+ if (!iFileServ) return KErrNoMemory;
+
+ err = iFileServ->Connect();
+ if (err)
+ {
+ delete iFileServ;
+ iFileServ = 0;
+ }
+ }
+ return err;
+ }
+
+void CObexBufObject::CloseFileServer()
+ {
+ if (iFileServ)
+ {
+ iFileServ->Close();
+ delete iFileServ;
+ iFileServ = 0;
+ }
+ }
+
+TInt CObexBufObject::WriteBufferToFile(TBool aFinal)
+ {
+ TInt err = KErrNone;
+
+ if (aFinal)
+ {
+ err = iWriter->FinalWrite(iBufOffset, iBuf, iBuffered);
+ }
+ else
+ {
+ err = iWriter->Write(iBufOffset, iBuf);
+ }
+
+ if (!iBuf && iDoubleBuf)
+ {
+ iBuf = iDoubleBuf;
+ }
+
+ iBuffered = 0;
+
+ return err;
+ }
+
+//
+// class CObexNullObject
+//
+void CObexNullObject::ConstructL()
+ {
+ CreateHeaderStorageDataL();
+ }
+
+/** Allocates and constructs a new null object.
+
+@return New null object
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexNullObject* CObexNullObject::NewL()
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexNullObject* self = new(ELeave) CObexNullObject;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return(self);
+ }
+
+/**
+To return "NULL" data, we simply set aDes.Size = 0
+*/
+void CObexNullObject::GetData(TInt /*aPos*/, TDes8& aDes)
+ {
+ aDes.SetLength(0);
+ return;
+ }
+
+/**
+In order to appear to consume the data, we don't set aDes.Size = 0
+*/
+void CObexNullObject::NewData(TInt /*aPos*/, TDes8& /*aDes*/)
+ {
+ return;
+ }
+
+TInt CObexNullObject::DataSize()
+ {
+ return(0);
+ }
+
+void CObexNullObject::ResetData()
+ {
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexpacketsignaller.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,221 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+ @internalComponent
+*/
+
+#include <obexfinalpacketobserver.h>
+#include "logger.h"
+#include "obexpacketsignaller.h"
+#include "OBEXUTIL.H"
+#include "obexfaults.h"
+#include "obexclient.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/** Constructor.
+This Active Object has a priority of EPriorityHigh + 1. This is to ensure
+that, when a final packet is sent, the RunLs are executed in the following order:
+1/ signaller (EObexFinalPacketStarted)
+2/ activeRW (the final packet actually being sent)
+3/ signaller (EObexFinalPacketFinished)
+The priority chosen is EPriorityHigh + 1 because the priorities of the
+transport controllers' writer (CActiveRW) AOs tends to be EPriorityHigh.
+As long as this is the case, our guarantee holds. Our documentation says that
+new licensee transport controllers must have writers with priorities that
+continue to support this guarantee.
+*/
+CObexPacketSignaller::CObexPacketSignaller() : CActive(CActive::EPriorityHigh + 1)
+ {
+ }
+
+/** Factory function.
+
+@return A fully constructed CObexPacketSignaller.
+*/
+CObexPacketSignaller* CObexPacketSignaller::NewL()
+ {
+ CObexPacketSignaller* signaller = new(ELeave)CObexPacketSignaller();
+ return signaller;
+ }
+
+/** Destructor.
+*/
+CObexPacketSignaller::~CObexPacketSignaller()
+ {
+ Cancel();
+ }
+
+/** Sets observer to be notified of packet process events.
+
+This clears any events that are currently outstanding.
+
+@param aObserver The observer to receive events. May be set to NULL.
+*/
+void CObexPacketSignaller::SetFinalPacketObserver(MObexFinalPacketObserver* aObserver)
+ {
+ LOG1(_L8("CObexPacketSignaller::SetObserver(0x%x)"), aObserver);
+
+ // Clear outstanding events for the final packet observer
+ // If there's an outstanding final packet event this means
+ // it won't get signalled.
+ iOutstandingEvents &= ~(EObexFinalPacketStarted | EObexFinalPacketFinished);
+
+ // Add or remove from scheduler if necessary
+ if(!iFinalPacketObserver &&!iReadActivityObserver && aObserver)
+ {
+ CActiveScheduler::Add(this);
+ }
+ else if(iFinalPacketObserver && !iReadActivityObserver && !aObserver)
+ {
+ Deque();
+ }
+
+ iFinalPacketObserver = aObserver;
+ }
+
+void CObexPacketSignaller::SetReadActivityObserver(MObexReadActivityObserver* aObserver)
+ {
+ LOG1(_L8("CObexPacketSignaller::SetObserver(0x%x)"), aObserver);
+
+ // Clear outstanding events for the read activity observer
+ // If there's an outstanding read activity event this means
+ // it won't get signalled.
+ iOutstandingEvents &= ~EObexReadActivityDetected;
+
+ //UpdateScheduler();
+ // Add or remove from scheduler if necessary
+ if(!iFinalPacketObserver &&!iReadActivityObserver && aObserver)
+ {
+ CActiveScheduler::Add(this);
+ }
+ else if(iReadActivityObserver && !iFinalPacketObserver && !aObserver)
+ {
+ Deque();
+ }
+
+ iReadActivityObserver = aObserver;
+ }
+
+
+/** Signal that an event has occurred.
+
+@param aEvent The event that has occurred.
+*/
+void CObexPacketSignaller::Signal(TObexPacketProcessEvent aEvent)
+ {
+ LOG1(_L8("CObexPacketSignaller::Signal(%d)"), aEvent);
+ __ASSERT_DEBUG((aEvent != 0), IrOBEXUtil::Panic(EBadPacketProcessEvent));
+
+ TBool appropriateObserver = EFalse;
+ switch(aEvent)
+ {
+ case EObexFinalPacketStarted:
+ case EObexFinalPacketFinished:
+ {
+ if(iFinalPacketObserver)
+ {
+ appropriateObserver = ETrue;
+ }
+ }
+ break;
+ case EObexReadActivityDetected:
+ {
+ if(iReadActivityObserver)
+ {
+ appropriateObserver = ETrue;
+ }
+ }
+ break;
+ default:
+ break; //drop - not for us
+ }
+
+ if(appropriateObserver)
+ {
+ iOutstandingEvents |= aEvent;
+
+ if(!IsActive())
+ {
+ SetActive();
+ TRequestStatus* status = &iStatus;
+ User::RequestComplete(status, KErrNone);
+ }
+ }
+ }
+
+/** Active object completion function.
+*/
+void CObexPacketSignaller::RunL()
+ {
+ LOG1(_L8("CObexPacketSignaller::RunL() with iOutstandingEvents %d"), iOutstandingEvents);
+
+ __ASSERT_DEBUG(iFinalPacketObserver || !(iOutstandingEvents & (EObexFinalPacketStarted | EObexFinalPacketFinished)),
+ IrOBEXUtil::Panic(ENoPacketProcessObserverSet));
+ __ASSERT_DEBUG(iReadActivityObserver || !(iOutstandingEvents & EObexReadActivityDetected),
+ IrOBEXUtil::Panic(ENoPacketProcessObserverSet));
+ // Signal each event in order
+ // Should be safe against an observer becoming
+ // unset as if it is unset then associated outstanding events are
+ // cleared.
+ if(iOutstandingEvents & EObexFinalPacketStarted)
+ {
+ iOutstandingEvents &= ~EObexFinalPacketStarted;
+ if(iFinalPacketObserver!=NULL)
+ {
+ iFinalPacketObserver->MofpoFinalPacketStarted();
+ }
+ }
+
+ if(iOutstandingEvents & EObexFinalPacketFinished)
+ {
+ iOutstandingEvents &= ~EObexFinalPacketFinished;
+ if(iFinalPacketObserver!=NULL)
+ {
+ iFinalPacketObserver->MofpoFinalPacketFinished();
+ }
+ }
+
+ if(iOutstandingEvents & EObexReadActivityDetected)
+ {
+ iOutstandingEvents &= ~EObexReadActivityDetected;
+ if(iReadActivityObserver!=NULL)
+ {
+ iReadActivityObserver->MoraoReadActivity();
+ }
+ }
+
+ // If we've been signalled as a result of client's notification
+ // handling events may be outstanding...
+ if(iOutstandingEvents)
+ {
+ SetActive();
+ TRequestStatus* status = &iStatus;
+ User::RequestComplete(status, KErrNone);
+ }
+ }
+
+/** From CActive.
+*/
+void CObexPacketSignaller::DoCancel()
+ {
+ iOutstandingEvents = 0;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexpackettimer.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,70 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+ @internalComponent
+*/
+
+#include "obexpackettimer.h"
+#include "obexclient.h"
+
+
+/*
+ * CObexPacketTimer. Will RunL if the remote obex server has not send any packet for a certain time.
+ * Duration is set by CObexClient::SetCommandTimeout
+ */
+
+CObexPacketTimer::CObexPacketTimer(CObexClient& aObexClient)
+ : CTimer(CActive::EPriorityStandard), iObexClient(aObexClient)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+CObexPacketTimer* CObexPacketTimer::NewL(CObexClient& aObexClient)
+ {
+ CObexPacketTimer* timer = new(ELeave)CObexPacketTimer(aObexClient);
+ CleanupStack::PushL(timer);
+ timer->ConstructL();
+ CleanupStack::Pop(timer);
+ return timer;
+ }
+
+CObexPacketTimer::~CObexPacketTimer()
+ {
+ Cancel();
+ }
+
+void CObexPacketTimer::RunL()
+ {
+ if(iStatus==KErrNone)
+ {
+ //Timeout
+ iObexClient.TimeOutCompletion();
+ }
+ }
+
+void CObexPacketTimer::SetTimer(TTimeIntervalMicroSeconds32 anInterval)
+ {
+ //Check if a timeout should be started on the request packet.
+ if(anInterval.Int()>KLowestPossibleTimerValue)
+ {
+ Cancel();
+
+ After(anInterval);
+ }
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexserver.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,1588 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <charconv.h>
+#include <utf.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obextransportinfo.h>
+#include <obex.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include <obex/internal/obextransportconstants.h>
+#include <obex/extensionapis/mobexserverrequestpacketnotify.h>
+#include <obex/internal/mobexserverrequestpacketnotifyregister.h>
+#include "logger.h"
+#include "obexsetpathdata.h"
+#include "OBEXUTIL.H"
+#include "authentication.h"
+#include "obexnotifyhandlerserver.h"
+#include "obexserverstatemachine.h"
+#include "obexservernotifysyncwrapper.h"
+#include "obexheaderutil.h"
+#include "obexserverrequestpacketengine.h"
+#include "obexpacketsignaller.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+Constructor - set initial values
+@internalTechnology
+*/
+CObexServer::CObexServer() : CObex()
+ {
+ iCurrentOperation = EOpIdle;
+ iEnabled = EFalse;
+
+ //the connectionID is fixed at the moment
+ ResetConnectionID();
+ SetConnectionID(0xc30fa596);
+
+ iTargetChecking = EIfPresent;
+ }
+
+void CObexServer::ConstructL(TObexTransportInfo& aObexTransportInfo)
+ {
+ CObex::ConstructL(aObexTransportInfo);
+ iNotifyHandler = new(ELeave)CObexNotifyHandlerServer(*this);
+ iTransportController->SetOwner(*iNotifyHandler);
+
+ iHeader = CObexHeader::NewL();
+ iStateMachine = CObexServerStateMachine::NewL(*this, *iTransportController);
+ iSyncWrapper = CObexServerNotifySyncWrapper::NewL(*this, *iStateMachine);
+ iPacketProcessSignaller = CObexPacketSignaller::NewL();
+ }
+
+/**
+Destructor.
+*/
+CObexServer::~CObexServer()
+ {
+ FLOG(_L("CObexServer Destructor\r\n"));
+ Stop();
+
+ delete iPacketProcessSignaller;
+ delete iSyncWrapper;
+ delete iStateMachine;
+ delete iHeader;
+ delete iNotifyHandler;
+ delete iServerRequestPacketEngine;
+ }
+
+void CObexServer::ResetConnectionID()
+ {
+ iConnectionID = KConnIDInvalid;
+ iConnectionIdSet = EFalse;
+ }
+
+void CObexServer::SetConnectionID(TUint32 aConnectionID)
+ {
+ iConnectionID = aConnectionID;
+ iConnectionIdSet = ETrue;
+ }
+
+TUint32 CObexServer::ConnectionID()
+ {
+ return (iConnectionID);
+ }
+
+TInt CObexServer::PrepareFinalChallResponse(CObexPacket& aPacket, TConnectState& aNextState)
+ {
+
+ FLOG(_L("CObexServer::PrepareFinalChallResponse\r\n"));
+
+ aPacket.SetOpcode(ERespSuccess);
+
+ TInt retValue = AddConnectionIDHeader(aPacket);
+ if (retValue == KErrNone)
+ {
+ FLOG(_L("PrepareFinalChallResponse ConnectionID header Added\r\n"));
+ if (iCallBack)
+ {
+ FLOG(_L("PrepareFinalChallResponse Requesting User Password\r\n"));
+
+ //the actual asking of the password happens later in the method OnPacketReceive
+ //wait for the reply
+ aNextState = EWaitForUserInput;
+ retValue = KErrGeneral; //mustn't send yet wait for reply from user
+ }
+ else //else can't Auth challenge so drop link
+ {
+ FLOG(_L("PrepareFinalChallResponse Can't request User Password for Chall dropping link\r\n"));
+
+ retValue = KErrIrObexConnectChallRejected;
+ aNextState = EConnTransport;
+ aPacket.SetOpcode(ERespNotImplemented);
+ }
+ }
+ else
+ {
+ aNextState = EDropLink;
+ }
+ return (retValue);
+ }
+
+
+/** A call back from the the service with the password required for use with generating
+the challenge response.
+
+@param aPassword Password
+
+@leave KErrNotReady if this function is not called from a MObexAuthChallengeHandler::GetUserPasswordL callback.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::UserPasswordL(const TDesC& aPassword)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ //now have a password, get a nonce, and get it hashed then reply
+ if (GetConnectState() == EWaitForUserInput)
+ {
+ FLOG(_L("CObexServer::UserPasswordL\r\n"));
+ PrepareChallResponseL(aPassword);
+ FLOG(_L("UserPasswordL - PrepareChallResponse Success\r\n"));
+
+ TObexInternalHeader hdr;
+ hdr.Set(TObexInternalHeader::EAuthResponse, (const_cast<TUint8*> (iOutgoingChallResp.Ptr())), iOutgoingChallResp.Size());
+ if(iTransportController->SendPacket().InsertData(hdr))
+ {
+ FLOG(_L("UserPasswordL Inserting EAuthResponse Header\r\n"));
+
+ SetConnectState(EConnObex); //all finished
+ iTransportController->SendPacket().SetFinal();
+ iTransportController->Send();
+ //inform the client that the connection was succesfull
+ iOwner->ObexConnectIndication(iRemoteInfo, TPtr8(NULL, 0));
+ iStateMachine->ConnectionComplete();
+ }
+ else
+ {
+ User::Leave(KErrGeneral);
+ }
+ }
+ else
+ {
+ User::Leave(KErrNotReady);
+ }
+ }
+
+
+TInt CObexServer::AddConnectionIDHeader(CObexPacket& aPacket)
+ {
+ TInt retValue = KErrNone;
+ //if the Target header was used for the connection
+ //then reply with ConnectionID and Who headers
+ if(iTargetReceived)
+ {
+ //this solution can only handle one connection at a time therefore
+ //can safely use the same connection ID repeatedly
+ //when used the ConnectionID must be first
+ TObexInternalHeader hdr;
+ FLOG(_L("CObexServer::AddConnectionIDHeader Inserting EConnectionID Header\r\n"));
+
+ hdr.Set(TObexInternalHeader::EConnectionID, iConnectionID);
+
+ if(aPacket.InsertData(hdr))
+ {
+ // Connection ID header inserted correctly
+ // Now set a WHO header.
+ // This logic is a bit backwards due to problems with the 'no target header checking'
+ // state. Instead of inserting our local Who header, we copy the Target header back.
+ // This works in the checking states because we drop any connection where the local
+ // Who is not identical to the Target header received.
+ // When not checking targets, this may mean that the client gets connected to a server
+ // which knows nothing about the service, yet thinks it is talking to a strict peer.
+ // However the server wouldn't understand what was going on anyway, so we're not really
+ // in a worse state than we would be if we did something more fancy. Ultimately the
+ // application must drop the connection---probably by deleting the Obex server or
+ // returning errors to all attempted operations.
+
+ FLOG(_L("CObexServer::AddConnectionIDHeader Inserting EWho Header\r\n"));
+
+ hdr.Set(TObexInternalHeader::EWho, (const_cast<TUint8*> (iRemoteInfo.iTargetHeader.Ptr())),
+ iRemoteInfo.iTargetHeader.Size());
+ if(!aPacket.InsertData(hdr))
+ {
+ retValue = KErrGeneral;
+ }
+ }
+ else
+ {
+ retValue = KErrGeneral;
+ }
+ }
+ return (retValue);
+ }
+
+/**
+Allocates and constructs a new OBEX server object.
+
+The received protocol information object, aObexProtocolInfoPtr, specifies the
+transport protocol to use:
+For the standard transports the following are used, TObexIrProtocolInfo for
+IrDA, TObexBluetoothProtocolInfo for Bluetooth, TObexUsbProtocolInfo for USB.
+
+@param aObexProtocolInfoPtr Protocol information object describing the
+transport to use
+@return New OBEX server object
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexServer* CObexServer::NewL(TObexProtocolInfo& aObexProtocolInfoPtr)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ TObexProtocolPolicy defaultProtocolPolicy; // no packet sizing policy specified, so use default
+ TObexTransportInfo* transportInfo = IrOBEXUtil::CreateTransportInfoL(aObexProtocolInfoPtr, defaultProtocolPolicy);
+ CleanupStack::PushL(transportInfo);
+ CObexServer* server = CObexServer::NewL(*transportInfo);
+ CleanupStack::PopAndDestroy(transportInfo);
+ return server;
+ }
+
+/**
+Allocates and constructs a new OBEX server object with packet sizing
+information.
+
+The received protocol information object, aObexProtocolInfoPtr, specifies the
+transport protocol to use:
+For the standard transports the following are used, TObexIrProtocolInfo for
+IrDA, TObexBluetoothProtocolInfo for Bluetooth, TObexUsbProtocolInfo for USB.
+
+The aObexProtocolPolicy parameter specifies the packet sizing policy for this
+OBEX object.
+
+@param aObexProtocolInfoPtr Protocol information object describing the
+transport to use
+@param aObexProtocolPolicy Protocol policy object specifying the packet sizes
+to use
+@return New OBEX server object
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexServer* CObexServer::NewL(TObexProtocolInfo& aObexProtocolInfoPtr,
+ TObexProtocolPolicy& aObexProtocolPolicy)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ TObexTransportInfo* transportInfo = IrOBEXUtil::CreateTransportInfoL(aObexProtocolInfoPtr, aObexProtocolPolicy);
+ CleanupStack::PushL(transportInfo);
+ CObexServer* server = CObexServer::NewL(*transportInfo);
+ CleanupStack::PopAndDestroy(transportInfo);
+ return server;
+ }
+
+/**
+Allocates and constructs a new OBEX server object with packet sizing
+information.
+
+The received transport information object, aObexTransportInfo, specifies the
+transport protocol and packet sizes to use:
+For the standard transports the following are used, TObexIrProtocolInfo for
+IrDA, TObexBluetoothProtocolInfo for Bluetooth, TObexUsbProtocolInfo for USB.
+
+@param aObexTransportInfo Transport information object describing the
+transport and packet sizes to use
+@return New OBEX server object
+
+@capability WriteDeviceData If the TObexIrV3TransportInfo is passed as the argument
+ and the associated name is valid.
+
+@publishedAll
+@released
+*/
+EXPORT_C CObexServer* CObexServer::NewL(TObexTransportInfo& aObexTransportInfo)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexServer* self = new(ELeave) CObexServer();
+ CleanupStack::PushL(self);
+ self->ConstructL(aObexTransportInfo);
+ CleanupStack::Pop(self);
+ return(self);
+ }
+
+/** Starts the server, specifying a synchronous notification interface.
+
+If the server is already started, no state changes occur (i.e. any connections/operations
+in progress are not interrupted), but the notifications will be sent to aOwner.
+This allows "child" servers to take over ownership of existing connections.
+
+Details of this function behaviour depend on the transport specified when
+constructed: in general a listener socket is created, its port number registered
+as appropriate, and an accept queued.
+
+@param aOwner Server notification interface
+@return KErrArgument if parameter is NULL, KErrAlreadyExists if server has already
+been started (but notification object will still be updated), otherwise a system wide
+error code
+@panic OBEX EChangeInterfaceDuringWait when attempting to change the interface at an inappropriate time.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::Start(MObexServerNotify* aOwner)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if(aOwner == NULL)
+ {
+ return(KErrArgument);
+ }
+
+ // Pass this synchronous interface to the synchronous wrapper
+ // and pass the synchronous wrapper on to the asynchronous Start()
+ iSyncWrapper->SetNotifier(aOwner);
+ return Start(iSyncWrapper);
+ }
+
+
+/** Starts the server, specifying an asynchronous notification interface.
+
+If the server is already started, no state changes occur (i.e. any connections/operations
+in progress are not interrupted), but the notifications will be sent to aOwner.
+This allows "child" servers to take over ownership of existing connections.
+
+Details of this function behaviour depend on the transport specified when
+constructed: in general a listener socket is created, its port number registered
+as appropriate, and an accept queued.
+
+@param aOwner Server notification interface
+@return KErrArgument if parameter is NULL, KErrAlreadyExists if server has already
+been started (but notification object will still be updated), otherwise a system wide
+error code
+@panic OBEX EChangeInterfaceDuringWait when attempting to change the interface at an inappropriate time.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::Start(MObexServerNotifyAsync* aOwner)
+ {
+ if(aOwner == NULL)
+ {
+ return(KErrArgument);
+ }
+
+ iOwner = aOwner;
+
+ iStateMachine->Start(*iOwner);
+ if(iEnabled)
+ {
+ return(KErrAlreadyExists);
+ }
+ iEnabled = ETrue;
+ return(AcceptConnection());
+ }
+
+
+/** Disconnects any transfer in progress and disables further connections.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::Stop()
+ {// Cancel and Disable accepts, and bring and transport down.
+ LOG_LINE
+ LOG_FUNC
+
+ if(!iEnabled)
+ {
+ return;
+ }
+ iEnabled = EFalse;
+ ControlledTransportDown();
+
+ // just check that iTransportController is still valid here (that is what we
+ // aspect to be)
+ __ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+
+ iTransportController->CancelAccept();
+ iStateMachine->Stop();
+ iOwner = NULL;
+ iSyncWrapper->SetNotifier(NULL);
+ }
+
+TInt CObexServer::AcceptConnection()
+ {
+ if(iEnabled && iOwner)
+ {
+ iCurrentOperation = EOpIdle;
+ TRAPD(err, iTransportController->AcceptConnectionL());
+ if(err != KErrNone)
+ {
+ iEnabled = EFalse;
+ }
+ return(err);
+ }
+ else
+ {
+ return(KErrNone);
+ }
+ }
+
+
+
+/** Sets a password required to access the server.
+
+When a password is set, a client must specify it to access the server.
+
+@param aPassword Password
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::SetChallengeL(const TDesC& aPassword)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ delete iChallPassword;
+ iChallPassword = NULL;
+ iChallPassword = HBufC8::NewL(aPassword.Length());
+ TPtr8 ptr = iChallPassword->Des();
+ CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr, aPassword);
+ iChallenge = ETrue;
+ }
+
+/** Resets the password.
+
+After this call, a client does not need to provide a password to access the
+server.
+
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::ResetChallenge()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ delete iChallPassword;
+ iChallPassword = NULL;
+ iChallenge = EFalse;
+ }
+
+/**
+Specifies target header checking behaviour.
+
+Supports three behaviours---never check, always check, and check only if a target
+header has been sent. The default behaviour is to only check when a target header
+has been sent.
+
+No checking allows a form of multiplexing to be used, where one server object may
+respond to multiple target headers. The behaviour desired by the client can be
+determined by examining the target header specified in the Connect.
+
+@param aChecking The desired level of target header checking.
+@publishedAll
+@released
+*/
+EXPORT_C void CObexServer::SetTargetChecking(TTargetChecking aChecking)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iTargetChecking = aChecking;
+ }
+
+
+/**
+Prepare next packet for the connection attempt
+ConnectionID and Who headers are Mandatory if the Target header was used in the connection from
+@param aPacket Packet to fill
+@internalComponent
+*/
+TInt CObexServer::PrepareConnectPacket(CObexPacket& aPacket)
+ {
+ FLOG(_L("CObexServer::PrepareConnectPacket\r\n"));
+ TInt retValue = KErrNone;
+ TConnectState nextState = GetConnectState();
+
+ if(!iTransportController->InsertLocalConnectInfo(aPacket, iLocalInfo.iVersion, iLocalInfo.iFlags))
+ {
+ FLOG(_L("PrepareConnectPacket Local data insertion FAILED\r\n"));
+ return(KErrGeneral);
+ }
+ FLOG(_L("PrepareConnectPacket Local data inserted\r\n"));
+
+ if(GetConnectState() == ESimpleConnRequest) //no Auth requested by the Client
+ {
+ FLOG(_L("PrepareConnectPacket GetConnectState() == ESimpleConnRequest\r\n"));
+ //if the Server must challenge
+ if(iChallenge)
+ {
+ FLOG(_L("PrepareConnectPacket Challenge Required\r\n"));
+
+ aPacket.SetOpcode(ERespUnauthorized);
+ retValue = GenerateChallenge(aPacket);
+ if ( retValue == KErrNone )
+ {
+ FLOG(_L("PrepareConnectPacket Challenge generated\r\n"));
+ nextState = ESimpleConnChallIssued;
+ }
+ else
+ {
+ FLOG(_L("PrepareConnectPacket Challenge generation FAILED\r\n"));
+ nextState = EConnTransport;
+ aPacket.SetOpcode(ERespInternalError);
+ }
+ }
+ else //don't require Authentication
+ {
+ FLOG(_L("PrepareConnectPacket No Challenge Required\r\n"));
+
+ aPacket.SetOpcode(ERespSuccess);
+ //if the Target header was used for the connection
+ //if so then reply with ConnectionID and Who headers
+ if ((retValue = AddConnectionIDHeader(aPacket)) == KErrNone)
+ {
+ FLOG(_L("PrepareConnectPacket ConnectionID Inserted\r\n"));
+ nextState = EConnObex;
+ }
+ else
+ {
+ nextState = EDropLink;
+ FLOG(_L("PrepareConnectPacket ConnectionID Insertion FAILED\r\n"));
+ }
+ }
+ } //end if(GetConnectState() == ESimpleConnRequest)
+ else if (GetConnectState() == EChallConnRequested)
+ {
+ FLOG(_L("PrepareConnectPacket GetConnectState() == EChallConnRequested\r\n"));
+
+ //if the Server must challenge
+ if(iChallenge)
+ {
+ FLOG(_L("PrepareConnectPacket Challenge required\r\n"));
+ aPacket.SetOpcode(ERespUnauthorized);
+ retValue = GenerateChallenge(aPacket);
+ if ( retValue == KErrNone )
+ {
+ FLOG(_L("PrepareConnectPacket Challenge Generated\r\n"));
+ nextState = EChallConnChallIssued; //chall answered with another chall
+ }
+ else
+ {
+ FLOG(_L("PrepareConnectPacket Challenge Generation FAILED\r\n"));
+ nextState = EConnTransport;
+ aPacket.SetOpcode(ERespInternalError);
+ }
+ }
+ else //don't require Authentication
+ { //the response would already have been verified in ParseConnectPacket()
+ //get password from user, prepare a response to the challenge
+ FLOG(_L("PrepareConnectPacket Challenge Not Required\r\n"));
+ retValue = PrepareFinalChallResponse(aPacket, nextState);
+ }
+ } //end else if GetConnectState() == EChallConnRequested
+ else if (GetConnectState() == EFinalChallRxed)
+ { //
+ retValue = PrepareFinalChallResponse(aPacket, nextState);
+ }
+ else if ( GetConnectState() == EFinalResponseReceived )
+ { //the response had to be OK otherwise would never have gotten this far
+ aPacket.SetOpcode(ERespSuccess);
+ //if the Target header was used for the connection
+ //if so then reply with ConnectionID and Who headers
+ if ((retValue = AddConnectionIDHeader(aPacket)) == KErrNone)
+ {
+ nextState = EConnObex;
+ FLOG(_L("PrepareConnectPacket ConnectionID header Added\r\n"));
+ }
+ else
+ {
+ nextState = EDropLink;
+ FLOG(_L("PrepareConnectPacket ConnectionID header Addition FAILED\r\n"));
+ }
+ }
+ else //it's all gone wrong
+ {
+ FLOG(_L("PrepareConnectPacket complete failure, bad state\r\n"));
+
+ //break connection, inform user
+ nextState = EConnTransport;
+ aPacket.SetOpcode(ERespInternalError);
+ retValue = KErrGeneral;
+ }
+ //if the Server is now connected inform the client
+ if ( nextState == EConnObex)
+ iOwner->ObexConnectIndication(iRemoteInfo, TPtr8(NULL, 0));
+
+ SetConnectState(nextState);
+ return(retValue);
+ }
+/**
+Prepare next packet for an invalid connection attempt (i.e. the ParseConnectPacket failed).
+A fail response (to a connect request) includes the version, flags, and packet size information.
+
+@param aPacket Packet to fill
+@internalComponent
+*/
+TInt CObexServer::PrepareErroredConnectPacket(CObexPacket& aPacket)
+ {
+ FLOG(_L("CObexServer::PrepareErroredConnectPacket\r\n"));
+
+ if ( !iTransportController->InsertLocalConnectInfo(aPacket, iLocalInfo.iVersion, iLocalInfo.iFlags))
+ {
+ FLOG(_L("PrepareConnectPacket Local data insertion FAILED\r\n"));
+ return(KErrGeneral);
+ }
+ return KErrNone;
+ }
+
+void CObexServer::SignalReadActivity()
+ {
+ iPacketProcessSignaller->Signal(EObexReadActivityDetected);
+ }
+
+void CObexServer::CheckTarget(TConnectState& aNextState, TInt& aRetVal)
+ {
+ FLOG(_L("Local Who:\r\n"));
+ LOGHEXDESC(iLocalInfo.iWho);
+ FLOG(_L("Target:\r\n"));
+ LOGHEXDESC(iRemoteInfo.iTargetHeader);
+
+ // Workaround for bug with PocketPC 2002---if target header is sixteen bytes of zeros, connect anyway.
+ _LIT8(KZeroTarget, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00");
+
+ // Allow connection iff:
+ // PocketPC attempting to connect to inbox (Sixteen bytes of zeros), when no LocalWho
+ // or Target header matches LocalWho (includes Inbox connections)
+
+ if (!( // Negate as block below discards connection
+ ((iLocalInfo.iWho == KNullDesC8) && (iRemoteInfo.iTargetHeader == KZeroTarget))
+ || ( iLocalInfo.iWho == iRemoteInfo.iTargetHeader)
+ ))
+ {
+ FLOG(_L("ParseConnectPacket ETarget header doesn't match local iWho, dropping link\r\n"));
+ aNextState = EConnTransport;
+ aRetVal = ERespNotFound;
+ }
+ }
+
+
+//if the Target header is sent then it must match the local iWho field
+TInt CObexServer::ParseConnectPacket(CObexPacket& aPacket)
+ {
+ TConnectState nextState = GetConnectState(); //must change otherwise it's all wrong
+ TBool challReceivedOK = EFalse; //authentication challenge received from client
+ //after server has issued its own authentication challenge.
+ TBool respReceivedOK = EFalse; //authentication received from client
+ //after server has issued its own authentication challenge.
+ FLOG(_L("CObexServer::ParseConnectPacket\r\n"));
+
+ if(!iTransportController->ExtractRemoteConnectInfo(aPacket, iRemoteInfo.iVersion, iRemoteInfo.iFlags))
+ {
+ FLOG(_L("ParseConnectPacket remote connect info extraction FAILED\r\n"));
+ return KErrGeneral;
+ }
+ FLOG(_L("ParseConnectPacket remote connect info extracted\r\n"));
+
+ TObexInternalHeader hdr;
+ iTargetReceived = EFalse; //if target received then must reply with ConnectionID
+
+ //if the present state is EConnTransport then no headers are actually
+ //required, a simple connect is sufficient
+ if(GetConnectState() == EConnTransport)
+ {
+ nextState = ESimpleConnRequest;
+ }
+
+ TInt retVal = KErrNone;
+ TBool authAttempted = EFalse;
+
+ while (aPacket.ExtractData(hdr) && (nextState != EDropLink) && (nextState != EConnTransport))
+ {
+ switch(hdr.HI())
+ {
+ case TObexInternalHeader::ETarget:
+ {
+ FLOG(_L("ParseConnectPacket extracting ETarget header\r\n"));
+ iTargetReceived = ETrue;
+ //copy the target header into iRemoteInfo for the user
+ iRemoteInfo.iTargetHeader.Copy(hdr.HVByteSeq(), hdr.HVSize() > iRemoteInfo.iTargetHeader.MaxSize() ? iRemoteInfo.iTargetHeader.MaxSize() : hdr.HVSize());
+
+ if (iTargetChecking == EIfPresent)
+ {
+ FLOG(_L("EIfPresent target header checking..."));
+ CheckTarget(nextState, retVal);
+ }
+ }
+ break;
+ case TObexInternalHeader::EAuthChallenge:
+ {
+ FLOG(_L("ParseConnectPacket EAuthChallenge Header received processing\r\n"));
+ authAttempted = ETrue;
+ TRAPD(err, ProcessChallengeL(hdr));
+ if (!err)
+ {
+ FLOG(_L("ParseConnectPacket Processing Chall SUCCESS\r\n"));
+ if (GetConnectState() == EConnTransport)
+ {
+ nextState = EChallConnRequested;
+ }
+ else if ((GetConnectState() == ESimpleConnChallIssued) || (GetConnectState() == EChallConnChallIssued))
+ {
+ challReceivedOK = ETrue; //the response must be verified first
+ nextState = EFinalChallRxed;
+ }
+ else
+ {
+ nextState = EConnTransport;
+ retVal = ERespInternalError;
+ }
+ }
+ else
+ {
+ FLOG(_L("ParseConnectPacket Processing Chall FAILED\r\n"));
+
+ nextState = EConnTransport;
+ retVal = ERespInternalError;
+ }
+ }
+ break;
+ case TObexInternalHeader::EAuthResponse:
+ {
+ if (iChallenge)
+ //else there is no challenge password to check against!
+ {
+ FLOG(_L("ParseConnectPacket EAuthResponse Header received processing\r\n"));
+ authAttempted = ETrue;
+ TRAPD(err, ProcessChallResponseL(hdr));
+ if (err == KErrNone)
+ {
+ FLOG(_L("ParseConnectPacket Processing Chall Response SUCCESS\r\n"));
+ if (GetConnectState() == ESimpleConnChallIssued)
+ {
+ respReceivedOK =ETrue;
+ if (challReceivedOK) //was a new challenge issued by the Client?
+ {
+ nextState = EFinalChallRxed; //must respond to chall
+ }
+ else
+ {
+ nextState = EFinalResponseReceived; //everything is OK send Success
+ }
+ }
+ else if (GetConnectState() == EChallConnChallIssued)
+ {
+ respReceivedOK =ETrue;
+ if (challReceivedOK) //was a new challenge issued by the Client?
+ {
+ nextState = EFinalChallRxed; //must respond to chall
+ }
+ else
+ {
+ //If we do not later in the packet see a challenge,
+ //(in which case this 'nextState' value will be overwritten),
+ //the client will have come back WITHOUT re-issuing
+ //either his original challenge or a new one.
+ //Treat as if client had never issued a challenge.
+ //This sequence has been observed in FOMA phones.
+ nextState = EFinalResponseReceived;
+ }
+ }
+ else
+ {
+ nextState = EConnTransport;
+ retVal = ERespInternalError;
+ }
+ }
+ else if (err == KErrAccessDenied)
+ {
+ nextState = EConnTransport;
+ retVal = ERespUnauthorized;
+ FLOG(_L("ParseConnectPacket Processing Chall Response FAILED with Access Denied\r\n"));
+ }
+ else
+ {
+ nextState = EConnTransport;
+ retVal = ERespInternalError;
+ FLOG(_L("ParseConnectPacket Processing Chall Response FAILED\r\n"));
+ }
+ }
+ else
+ {
+ // if no challenge was issued, then receiving a challenge response means the peer is badly
+ // behaved. For this case we simply ignore the header, anything else would be too drastic.
+ FLOG(_L("ParseConnectPacket Chall Response received when no Chall issued\r\n"));
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (((GetConnectState() == ESimpleConnChallIssued) || (GetConnectState() == EChallConnChallIssued)) && !respReceivedOK)
+ // Client's connect packet should have contained an authentication response.
+ // Treat as if we had rejected an authentication response.
+ {
+ nextState = EConnTransport;
+ retVal = ERespUnauthorized;
+ }
+
+ if (iTargetChecking == EAlways)
+ {
+ FLOG(_L("EAlways target header checking..."));
+ CheckTarget(nextState, retVal);
+ }
+
+ if (!authAttempted && (GetConnectState() == ESimpleConnChallIssued))
+ nextState = ESimpleConnRequest;
+
+ SetConnectState(nextState);
+
+ return retVal;
+ }
+
+
+/**
+Check, if required, the object connection ID.
+
+@return ETrue if it was not necessary to receive the ConnectionID or
+ if it was necessary and was correctly received. Otherwise
+ EFalse.
+@internalComponent
+*/
+TBool CObexServer::CheckObjectForConnectionId(CObexBaseObject& aObject)
+ {
+ TBool retValue = ETrue;
+
+ if( iTargetReceived )
+ {
+ retValue = EFalse;
+ if (aObject.iValidHeaders & KObexHdrConnectionID )
+ {
+ TUint32 connID = aObject.ConnectionID();
+ if (iConnectionIdSet && (iConnectionID == connID))
+ {
+ retValue = ETrue;
+ }
+ }
+ }
+ return (retValue);
+ }
+
+/**
+Check, if required, that the packet connection ID matches that of the Server's current connection
+@return ETrue if the connection ID matches or if Target was not used in the original connection
+@return EFalse if Target was not used in the original connection and the connection ID was not found
+@internalComponent
+*/
+TBool CObexServer::CheckPacketForConnectionId(CObexPacket& aPacket)
+ {
+ // Connection ID check is compulsory if Target was used in the original connection
+ if (!iTargetReceived)
+ {
+ return ETrue;
+ }
+
+ // Search for ConnectionID
+ // ConnectionID should be the first header, but we check all of them just in case
+ TObexInternalHeader header;
+ while (aPacket.ExtractData(header))
+ {
+ if (header.HI() == TObexInternalHeader::EConnectionID)
+ {
+ TUint32 newConnectionID = (header.HVByteSeq()[0] << 24) + (header.HVByteSeq()[1] << 16)
+ + (header.HVByteSeq()[2] << 8) + (header.HVByteSeq()[3]);
+
+ if (ConnectionID() == newConnectionID)
+ {
+ return ETrue;
+ }
+ }
+ }
+
+ // Target was used in original connection and could not find Connection ID
+ return EFalse;
+ }
+
+void CObexServer::OnPacketReceive(CObexPacket& aPacket)
+ {
+ FLOG(_L("CObexServer::OnPacketReceive\r\n"));
+ MObexServerRequestPacketNotify* packetNotify = NULL;
+ if (iServerRequestPacketEngine)
+ {
+ packetNotify = iServerRequestPacketEngine->RequestPacketNotify();
+ }
+ // If a packet notify has been registered then we should tell it
+ // about each request packet we receive.
+ if (packetNotify)
+ {
+ TObexResponse response;
+ TBool normalOperation = ETrue;
+
+ // Rebuild full OBEX opcode to pass to observer
+ TObexOpcode opcode = aPacket.Opcode() | (aPacket.IsFinal() ? KObexPacketFinalBit : 0);
+
+ switch (aPacket.Opcode())
+ {
+ case CObex::EOpConnect:
+ {
+ TObexConnectInfo connectInfo;
+ if (!iStateMachine->Transport().ExtractRemoteConnectInfo(aPacket, connectInfo.iVersion, connectInfo.iFlags))
+ {
+ // If the packet cannot be parsed correctly at this stage it is very malformed
+ // and so we should abort processing it for the server app, and defer handling
+ // the error to the state machine.
+ break;
+ }
+
+ TObexInternalHeader header;
+ // Call ExtractData() until it returns 0 bytes read - then we know the extract
+ // point will have been reset so the CObexPacket can be parsed again in the
+ // future. For this reason do not attempt to optimise this loop.
+ while (aPacket.ExtractData(header))
+ {
+ switch (header.HI())
+ {
+ case TObexInternalHeader::ETarget:
+ // Only take the first Target header found
+ if (connectInfo.iTargetHeader.Length() == 0)
+ {
+ TInt size = header.HVSize() > connectInfo.iTargetHeader.MaxSize() ? connectInfo.iTargetHeader.MaxSize() : header.HVSize();
+ connectInfo.iTargetHeader.Copy(header.HVByteSeq(), size);
+ }
+ break;
+ case TObexInternalHeader::EWho:
+ // Return the first Who header in packet
+ if (connectInfo.iWho.Length() == 0)
+ {
+ TInt size = header.HVSize() > connectInfo.iWho.MaxSize() ? connectInfo.iWho.MaxSize() : header.HVSize();
+ connectInfo.iWho.Copy(header.HVByteSeq(), size);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ normalOperation = packetNotify->RequestPacket(opcode, connectInfo, response);
+ }
+ break;
+ case CObex::EOpSetPath:
+ {
+ TObexSetPathData data;
+
+ if (!aPacket.ExtractData(data))
+ {
+ // If the packet cannot be parsed correctly at this stage it is very malformed
+ // and so we should abort processing it for the server app, and defer handling
+ // the error to the state machine.
+ break;
+ }
+ CObex::TSetPathInfo info(data);
+
+ TObexInternalHeader header;
+ // Call ExtractData() until it returns 0 bytes read - then we know the extract
+ // point will have been reset so the CObexPacket can be parsed again in the
+ // future. For this reason do not attempt to optimise this loop.
+ while(aPacket.ExtractData(header))
+ {
+ // Take the first name header we find.
+ if(!info.iNamePresent && header.HI() == TObexInternalHeader::EName && header.GetHVText(info.iName) == KErrNone)
+ {
+ info.iNamePresent = ETrue;
+ }
+ }
+
+ normalOperation = packetNotify->RequestPacket(opcode, info, response);
+ }
+ break;
+ case CObex::EOpDisconnect:
+ case CObex::EOpAbortNoFBit:
+ case CObex::EOpPut:
+ case CObex::EOpGet:
+ default:
+ normalOperation = packetNotify->RequestPacket(opcode, response);
+ break;
+ }
+
+ if (!normalOperation) // Abandon processing of request
+ {
+ CheckServerAppResponseCode(aPacket.Opcode(), response); // a success response code => panic
+ iStateMachine->OverrideRequestHandling(response);
+ return;
+ }
+ }
+
+ // Normal processing
+ iStateMachine->OnPacketReceive(aPacket);
+ }
+
+/**
+This function is to ensure that a response a server application provides the Obex Server
+to respond to the Obex Client with when it has overriden the default handling of a request
+packet does not represent a success.
+
+The rationale for this is to attempt to keep the Obex peers synchronised. As the packet has
+been dropped, the client should not be lead to believe it has been received successfully.
+
+Therefore, this function asserts that the application does not send a success response for
+the request packet received.
+*/
+void CObexServer::CheckServerAppResponseCode(TObexOpcode aOpcode, TObexResponse aResponse)
+ {
+ TBool valid = ETrue;
+ switch (aOpcode)
+ {
+ case CObex::EOpConnect:
+ if (aResponse == ERespSuccess)
+ {
+ valid = EFalse;
+ }
+ break;
+ case CObex::EOpPut:
+ case CObex::EOpGet:
+ if (aResponse == ERespSuccess || aResponse == ERespContinue)
+ {
+ valid = EFalse;
+ }
+ break;
+ case CObex::EOpSetPath:
+ if (aResponse == ERespSuccess)
+ {
+ valid = EFalse;
+ }
+ break;
+ case CObex::EOpDisconnect:
+ case CObex::EOpAbortNoFBit:
+ // We allow any response to a abort/disconnect request,
+ // as only success codes are allowed.
+ default:
+ break;
+ }
+ __ASSERT_ALWAYS(valid, IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+ }
+
+void CObexServer::OnError(TInt aError)
+ {
+ FTRACE(FPrint(_L("OnError aError: %d iCurrentOperation: %d, iConnectState: %d"), aError, iCurrentOperation, iConnectState));
+
+ if (aError == KErrDisconnected)
+ {
+ // Note: It is not clear that iCurrentOperation is ever equal
+ // to EOpDisconnect but the check has been retained just in case
+ if ((iCurrentOperation != EOpDisconnect) && (iConnectState > EConnTransport))
+ {
+ //extended error for IrObex,("peer device aborted data transmission/obex sending")
+ iOwner->ErrorIndication(KErrIrObexServerPutPeerAborted);
+ }
+ }
+ else
+ {
+ iOwner->ErrorIndication(aError);
+ }
+ // The state machine needs to know about the error regardless of whether ErrorIndication() is called
+ iStateMachine->Error();
+ }
+
+void CObexServer::OnTransportUp()
+ {
+ iTargetReceived = EFalse;
+
+ // For servers on the device using USB, there is a possibility that
+ // this function can be called, even though the server is stopped,
+ // as OBEX does not control the transport, the USB host does.
+ // Hence the need to check if there is an active iOwner.
+ if (iOwner)
+ {
+ iOwner->TransportUpIndication();
+ }
+ iStateMachine->TransportUp(); // state machine needs to know about the event regardless of Server state
+ }
+
+/**
+Tell the MObexServerNotifyAsync observer the transport is down and listen
+for another connection.
+*/
+void CObexServer::OnTransportDown()
+ {// Cancel Anything waiting. Restart the accepter
+
+ // For servers on the device using USB, there is a possibility that
+ // this function can be called, even though the server is stopped,
+ // as OBEX does not control the transport, the USB host does
+ // Hence the need to check if there is an active iOwner.
+ if (iOwner)
+ {
+ iOwner->TransportDownIndication();
+ }
+ iStateMachine->TransportDown(); // state machine needs to know about the event regardless of Server state
+ TInt err = AcceptConnection();
+ if(err != KErrNone)
+ Error(err);
+ }
+
+/** Signals an event has ocurred.
+
+@released
+@internalComponent
+@param aEvent The event that has occurred. (TObexPacketProcessEvent)
+*/
+void CObexServer::SignalPacketProcessEvent(TInt aEvent)
+ {
+ LOG_FUNC
+
+ // This is how we signal the completed send of an ACK to a disconnect
+ // command. Tell the state machine so it can finish the disconnection
+ // sequence.
+ if(aEvent & EObexWriteCompletedFinal)
+ {
+ iStateMachine->WriteComplete();
+ }
+
+ // Server will have definitely finished with the read packet so queue the next read
+ if(aEvent & EObexWriteCompleted)
+ {
+ iTransportController->Receive();
+ }
+
+ if(aEvent & EObexReadActivityDetected)
+ {
+ iStateMachine->ReadActivityDetected();
+ }
+ }
+
+// CObexServer
+/** Tests if the server is started, and is available to accept connections.
+
+@return ETrue if the server is started, EFalse otherwise
+
+@publishedAll
+@released
+*/
+EXPORT_C TBool CObexServer::IsStarted()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iEnabled;
+ }
+
+/**
+Returns the operation currently being performed by the remote client, or
+EOpIdle if between operations. Note that there is no implication of whether
+the server is currently connected; EOpIdle will be returned regardless of
+connection state, if no operation is currently being performed. Use
+CObex::IsConnected () to find connection staus.
+
+@return Operation currently being performed by the remote client
+
+@publishedAll
+@released
+*/
+EXPORT_C CObex::TOperation CObexServer::CurrentOperation() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iCurrentOperation;
+ }
+
+/**
+Setter function to allow other classes in the DLL to set the Server's current operation.
+Used by the Server state machine.
+@see CObexServerStateMachine
+@param aOperation The operation currently being performed by the remote client
+@internalComponent
+*/
+void CObexServer::SetCurrentOperation(const CObex::TOperation aOperation)
+ {
+ iCurrentOperation = aOperation;
+ }
+
+/**
+Specify the set of headers to return to remote Obex client in final
+Put response packet. The total length of the headers when encoded
+should not exceed the maximum Obex packet payload size.
+
+This function may be called at any point during a Put operation.
+Repeated calls to this replace rather than add to the header set
+for inclusion in the final Put response packet.
+
+It may be called with a NULL pointer, which means that no headers
+will be sent with the Put Final Response.
+
+Even if this function returns with an error (even KErrNotReady) a
+best-effort attempt will be made to send as many headers as will fit
+in the final Put response packet.
+
+@param aHeaderSet A set of headers to be encoded in the final Put
+response packet. Ownership of the header set always passes to
+CObexServer.
+
+@return KErrNone if the operation completes successfully.
+ KErrNotReady if the current operation is not a Put.
+ KErrArgument if the length of the headers when encoded
+ exceeds the maximum Obex packet payload size.
+
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::SetPutFinalResponseHeaders(CObexHeaderSet* aHeaderSet)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // First, let the state machine take ownership of the headerset
+ iStateMachine->SetPutFinalResponseHeaderSet(aHeaderSet);
+
+ TInt err=KErrNone;
+
+ // Easy check first - are we currently engaged in a Put?
+ if(iCurrentOperation != EOpPut)
+ {
+ err=KErrNotReady;
+ }
+
+ if(!err && aHeaderSet)
+ {
+ // Next, the not so easy check. Will all the headers, when encoded,
+ // fit inside a send packet?
+ // First, how much space do we have to play with?
+ TInt available = iTransportController->SendPacket().DataLimit() - KObexPacketHeaderSize;
+
+ // Next, what is the combined encoded size of all the headers?
+ TInt required = 0;
+ aHeaderSet->First();
+ while(aHeaderSet->This(iHeader) == KErrNone)
+ {
+ required+=iHeader->EncodedSize();
+ (void)aHeaderSet->Next();
+ }
+
+ if(required>available)
+ {
+ err=KErrArgument;
+ }
+ }
+
+ return err;
+ }
+
+
+/**
+Complete an asynchronous callback, supplying a CObexBaseObject derived object.
+Passing in NULL results in an Obex level error being sent to the client -- the
+semantics are that either a PUT request has been rejected or a GET request has
+not found a suitable object to return.
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@param aObject The object passed back from application
+@return result of state changes
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::RequestIndicationCallback(CObexBaseObject* aObject)
+ {
+ LOG_LINE
+ LOG_FUNC
+ return iStateMachine->RequestNotificationCompleted(aObject);
+ }
+
+/**
+Complete an asynchronous callback, supplying a obex response code. Applications
+should use this function when rejecting Get/Put RequestIndication in order to
+specify the response code.
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@panic Obex EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode is outside range
+[1,255] or it is one of the successful response (e.g. ERespSuccess, ERespContinue)
+@param TObexResponse aResponseCode Application's response to the indication as an Obex response Code. The Final bit is ignored.
+@return result of state changes
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::RequestIndicationCallbackWithError(TObexResponse aResponseCode)
+ {
+ LOG_LINE
+ LOG_FUNC
+ return iStateMachine->RequestNotificationCompleted(aResponseCode);
+ }
+
+/**
+Complete an asynchronous callback, supplying a obex response code. Applications
+should use this function when rejecting Get/Put RequestIndication in order to
+specify the error code.
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@panic Obex EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode non-negtive. Note: KErrNone is
+not acceptable because this function is only used when there is an error.
+@param aErrorCode Application's response to the indication as an Obex response Code.
+@return result of state changes
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::RequestIndicationCallbackWithError(TInt aErrorCode)
+ {
+ LOG_LINE
+ LOG_FUNC
+ __ASSERT_ALWAYS(aErrorCode <= 0, IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+ return iStateMachine->RequestNotificationCompleted(IrOBEXUtil::ObexResponse(aErrorCode, ERespSuccess));
+ }
+
+
+/**
+Complete an asynchronous callback, supplying a obex response code. This function is
+used for asychronously handling PutComplete, GetComplete and SetPath Indication.
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@panic Obex EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode is outside range
+[1,255] or it is ERespContinue (which would confuse the client)
+@param TObexResponse aResponseCode Application's response to the indication as an Obex response Code. The Final bit is ignored.
+@return result of state changes
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::RequestCompleteIndicationCallback(TObexResponse aResponseCode)
+ {
+ LOG_LINE
+ LOG_FUNC
+ return iStateMachine->RequestCompleteNotificationCompleted(aResponseCode);
+ }
+
+/**
+Complete an asynchronous callback, supplying a obex response code. This function is
+used for asychronously handling PutComplete, GetComplete and SetPath Indication.
+
+@panic Obex ENoNotificationToComplete Raised if the server does not have a request
+outstanding.
+@panic Obex EInvalidResponseCodeFromServerApp raised if aErrorCode is positive, i.e.
+invalid Symbian error code
+@param TObexResponse aResponseCode Application's response to the indication as a Symbian error code
+@return result of state changes
+@publishedAll
+@released
+*/
+EXPORT_C TInt CObexServer::RequestCompleteIndicationCallback(TInt aErrorCode)
+ {
+ LOG_LINE
+ LOG_FUNC
+ __ASSERT_ALWAYS(aErrorCode <= 0, IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+ return iStateMachine->RequestCompleteNotificationCompleted(IrOBEXUtil::ObexResponse(aErrorCode, ERespSuccess));
+ }
+
+/**
+Provides the pre-parsed contents of the most recently received request packet.
+
+@param aHeaderSet A reference to a pointer that will be modified to NULL if no headers
+are contained in the request packet, or to point to a new headerset containing
+representations of the headers within the packet. Ownership of the headerset
+(when aHeaderSet is not NULL) is passed to the caller.
+@return KErrNone if successful, otherwise a system wide error code.
+
+@publishedPartner
+@released
+*/
+EXPORT_C TInt CObexServer::PacketHeaders(CObexHeaderSet*& aHeaderSet)
+ {
+ FLOG(_L8("CObexServer::PacketHeaders"));
+
+ return DoPacketHeaders(aHeaderSet, NULL);
+ }
+
+
+/**
+Provides the selectively pre-parsed contents of the most recently received request packet.
+
+@param aHeaderSet A reference to a pointer that will be modified to NULL if no interesting
+header are contained in the request packet, or to point to a new headerset containing
+representations of the headers within the packet that are of interest. Ownership of the
+headerset (when aHeaderSet is not NULL) is passed to the caller.
+@param aHeaderCheck A reference to an MObexHeaderCheck derived class that encapsulates
+whether or not a particular header or headers should be included in the returned header
+set (i.e. whether the headers are "interesting").
+
+@return KErrNone if successful, otherwise a system wide error code.
+
+@publishedPartner
+@released
+*/
+EXPORT_C TInt CObexServer::PacketHeaders(CObexHeaderSet*& aHeaderSet, MObexHeaderCheck& aHeaderCheck)
+ {
+ FLOG(_L8("CObexServer::PacketHeaders (selective)"));
+
+ return DoPacketHeaders(aHeaderSet, &aHeaderCheck);
+ }
+
+/** Sets a read activity observer.
+
+This replaces any previous observer. The observer will receive a callback
+when the first read arrives for a put or get request.
+
+This does not transfer ownership.
+
+@publishedPartner
+@released
+@param aObserver The observer to receive packet process events. This may
+ be NULL.
+*/
+EXPORT_C void CObexServer::SetReadActivityObserver(MObexReadActivityObserver* aObserver)
+ {
+ iPacketProcessSignaller->SetReadActivityObserver(aObserver);
+ }
+/**
+Contains the functionality for the PacketHeader interface functions in a refactored way.
+
+@param aHeaderSet A reference to a pointer that will be modified to NULL if no interesting
+header are contained in the request packet, or to point to a new headerset containing
+representations of the headers within the packet that are of interest. Ownership of the
+headerset (when aHeaderSet is not NULL) is passed to the caller.
+@param aHeaderCheck A pointer to an MObexHeaderCheck derived class that encapsulates
+whether or not a particular header or headers should be included in the returned header
+set (i.e. whether the headers are "interesting"). If the pointer is NULL then that is taken
+to mean that all headers should be added to the aHeaderSet.
+
+@return KErrNone if successful, otherwise a system wide error code.
+*/
+TInt CObexServer::DoPacketHeaders(CObexHeaderSet*& aHeaderSet, MObexHeaderCheck* aHeaderCheck)
+ {
+ FLOG(_L8("CObexServer::DoPacketHeaders"));
+
+ TRAPD(err, aHeaderSet = CObexHeaderSet::NewL());
+ if (err != KErrNone)
+ {
+ aHeaderSet = NULL;
+ return err;
+ }
+
+ CObexPacket& packet = iTransportController->ReceivePacket();
+
+ // for "non-standard" size requests ensure we correctly start
+ // extracting headers where they start.
+ switch (packet.Opcode())
+ {
+ case CObex::EOpConnect:
+ {
+ TObexConnectInfo connectInfo;
+ if (!iStateMachine->Transport().ExtractRemoteConnectInfo(packet, connectInfo.iVersion, connectInfo.iFlags))
+ {
+ err = KErrUnderflow;
+ }
+ }
+ break;
+ case CObex::EOpSetPath:
+ {
+ TObexSetPathData data;
+ if (!packet.ExtractData(data))
+ {
+ err = KErrUnderflow;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ TBool interestingHeaders = EFalse;
+ TObexInternalHeader header;
+ // Call ExtractData() until it returns 0 bytes read - then we know the extract
+ // point will have been reset so the CObexPacket can be parsed again in the
+ // future. For this reason do not attempt to optimise this loop.
+ while(packet.ExtractData(header))
+ {
+ // if there was an error previously we want to just keep going through the
+ // loop to reset the CObexPacket extraction point.
+ if (err == KErrNone && (!aHeaderCheck || aHeaderCheck->Interested(header.HI())))
+ {
+ err = IrOBEXHeaderUtil::ParseHeader(header, *aHeaderSet);
+ if (!interestingHeaders && err == KErrNone)
+ {
+ interestingHeaders = ETrue;
+ }
+ }
+ }
+
+ if (err != KErrNone || !interestingHeaders)
+ {
+ delete aHeaderSet;
+ aHeaderSet = NULL;
+ }
+ return err;
+ }
+
+/**
+Provides additional interfaces for CObexServer.
+
+@param aUid The UID of the interface that is required.
+@return A pointer to an instance implementing the interface represented by aUid.
+
+@leave KErrNotSupported if the given UID does not represent an interface CObexServer can provide.
+@leave KErrInUse if an instance of MObexServerRequestPacketNotifyRegister has already been provided
+ by an earlier call to ExtensionInterfaceL, and it has not been released.
+
+@internalTechnology
+*/
+EXPORT_C TAny* CObexServer::ExtensionInterfaceL(TUid aUid)
+ {
+ // MObexServerRequestPacketNotifyRegister interface
+ if (aUid == KObexServerRequestPacketNotifyRegisterInterface)
+ {
+ // We only return an instance if there are no other packet access extensions
+ // hooked into the CObexServer instance (indicated by the existance of an engine).
+ if (iServerRequestPacketEngine)
+ {
+ User::Leave(KErrInUse);
+ }
+ iServerRequestPacketEngine = CObexServerRequestPacketEngine::NewL(*this);
+ return static_cast<MObexServerRequestPacketNotifyRegister*>(iServerRequestPacketEngine);
+ }
+ // if we don't know the interface UID then we don't support it.
+ User::Leave(KErrNotSupported);
+ return NULL; // to silence the compiler.
+ }
+
+/**
+Returns a pointer to the TObexTransportInfo being used by the OBEX transport
+layer. THE USER MUST NOT MODIFY THE OBJECT POINTED TO.
+This is useful primarily when using OBEX over RFCOMM and the user has
+specified 'KRfcommPassiveAutoBind' as the port. KRfcommPassiveAutoBind makes
+RFCOMM itself find a free port. The user needs to know which port is really
+being used by RFCOMM in order to correctly populate the SDP record.
+May be called meaningfully after CObexServer::Start has returned KErrNone.
+@return Pointer to the transport layer's transport info.
+@publishedAll
+@released
+*/
+EXPORT_C const TObexTransportInfo* CObexServer::TransportInfo() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iTransportController, IrOBEXUtil::Fault(ETransportControllerNotCreated));
+ return iTransportController->TransportInfo();
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexservernotify.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,43 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedAll
+*/
+
+#include <obexserver.h>
+
+/**
+This virtual function allows the M- classes to be extended in future in a binary
+compatible way by providing a method that clients can override in future to
+allow extra callbacks to be made via aObject.
+*/
+EXPORT_C void MObexServerNotify::MOSN_ExtensionInterfaceL(TUid /*aInterface*/, void*& aObject)
+ {
+ aObject = NULL;
+ }
+
+/**
+This virtual function allows the M- classes to be extended in future in a binary
+compatible way by providing a method that clients can override in future to
+allow extra callbacks to be made via aObject.
+*/
+EXPORT_C void MObexServerNotifyAsync::MOSNA_ExtensionInterfaceL(TUid /*aInterface*/, void*& aObject)
+ {
+ aObject = NULL;
+ }
+
+// EOF
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexservernotifysyncwrapper.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,187 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// All methods in this file act either to initialise the wrapper object or to forward calls
+// from the async server notify class to the synchronous version.
+//
+//
+
+/**
+ @file
+ @internalComponent
+ @see MObexServerNotify
+ @see MObexServerNotifyAsync
+*/
+
+#include <e32base.h>
+#include <obexserver.h>
+#include <obexobjects.h>
+#include "logger.h"
+#include "OBEXUTIL.H"
+#include "obexservernotifysyncwrapper.h"
+#include "obexserverstatemachine.h"
+
+
+#ifdef _DEBUG
+// Save the return value as debugger will (hopefully) then make it easier to see...
+#define CHECK_NOERROR(expr) TInt _saved_error = (expr); __ASSERT_ALWAYS(_saved_error == KErrNone, IrOBEXUtil::Fault(ESyncWrapperCallbackError));
+#else
+#define CHECK_NOERROR(expr) (void)expr
+#endif
+//
+// Initialisation methods
+//
+CObexServerNotifySyncWrapper* CObexServerNotifySyncWrapper::NewL(CObexServer& aOwner, CObexServerStateMachine& aStateMachine)
+ {
+ CObexServerNotifySyncWrapper* self = new (ELeave) CObexServerNotifySyncWrapper(aOwner, aStateMachine);
+ return self;
+ }
+
+CObexServerNotifySyncWrapper::CObexServerNotifySyncWrapper(CObexServer& aOwner, CObexServerStateMachine& aStateMachine)
+ : iOwner(aOwner), iStateMachine(aStateMachine)
+ {}
+
+CObexServerNotifySyncWrapper::~CObexServerNotifySyncWrapper()
+ {
+ }
+
+void CObexServerNotifySyncWrapper::SetNotifier(MObexServerNotify* aNotify)
+ {
+ // if aNotify is NULL this will cause any forwarding methods to dereference NULL.
+ // But this should never happen. K-E 3 will result if they do, but all we'd
+ // do otherwise would be to panic anyway...
+ iNotify = aNotify;
+ }
+
+//
+// Forwarding methods
+//
+void CObexServerNotifySyncWrapper::ErrorIndication(TInt aError)
+ {
+ iNotify->ErrorIndication(aError);
+ }
+
+void CObexServerNotifySyncWrapper::TransportUpIndication()
+ {
+ iNotify->TransportUpIndication();
+ }
+
+void CObexServerNotifySyncWrapper::TransportDownIndication()
+ {
+ iNotify->TransportDownIndication();
+ }
+
+void CObexServerNotifySyncWrapper::ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo)
+ {
+ // Explicitly code that we're ignoring the return value. See the doxygen comment.
+ (void)iNotify->ObexConnectIndication(aRemoteInfo, aInfo);
+ }
+
+void CObexServerNotifySyncWrapper::ObexDisconnectIndication(const TDesC8& aInfo)
+ {
+ iNotify->ObexDisconnectIndication(aInfo);
+ }
+
+//
+// Forward the request to the MObexServerNotify implementation, then immediately
+// downcall into CObexServer.
+//
+void CObexServerNotifySyncWrapper::PutRequestIndication()
+ {
+ WRAPPER_LOG(_L8("Put request indication"));
+ iCallbackOutstanding = ETrue;
+ iStateMachine.SetAppResponse(ERespSuccess);
+ // A NULL return here is OK as it is the response to reject the request.
+ CObexBaseObject* object = iNotify->PutRequestIndication();
+
+ WRAPPER_LOG(_L8("Put request indication complete"));
+ if(iCallbackOutstanding && (iStateMachine.AppResponse() == ERespSuccess))
+ {
+ CHECK_NOERROR(iOwner.RequestIndicationCallback(object));
+ }
+ }
+
+TInt CObexServerNotifySyncWrapper::PutPacketIndication()
+ {
+ return iNotify->PutPacketIndication();
+ }
+
+void CObexServerNotifySyncWrapper::PutCompleteIndication()
+ {
+ iCallbackOutstanding = ETrue;
+ TInt err = iNotify->PutCompleteIndication();
+ TObexResponse resp = IrOBEXUtil::ObexResponse(err, ERespSuccess);
+ if(iCallbackOutstanding)
+ {
+ CHECK_NOERROR(iOwner.RequestCompleteIndicationCallback(resp));
+ }
+ }
+
+//
+// Forward the request to the MObexServerNotify implementation, then immediately
+// downcall into CObexServer.
+//
+void CObexServerNotifySyncWrapper::GetRequestIndication(CObexBaseObject* aRequiredObject)
+ {
+ WRAPPER_LOG(_L8("Get request indication"));
+ iCallbackOutstanding = ETrue;
+ iStateMachine.SetAppResponse(ERespSuccess);
+ // A NULL return here is OK as it is the response to reject the request.
+ CObexBaseObject* object = iNotify->GetRequestIndication(aRequiredObject);
+
+ WRAPPER_LOG(_L8("Get request indication complete"));
+ if(iCallbackOutstanding && (iStateMachine.AppResponse() == ERespSuccess))
+ {
+ CHECK_NOERROR(iOwner.RequestIndicationCallback(object));
+ }
+ }
+
+TInt CObexServerNotifySyncWrapper::GetPacketIndication()
+ {
+ return iNotify->GetPacketIndication();
+ }
+
+void CObexServerNotifySyncWrapper::GetCompleteIndication()
+ {
+ iCallbackOutstanding = ETrue;
+ TInt err = iNotify->GetCompleteIndication();
+ TObexResponse resp = IrOBEXUtil::ObexResponse(err, ERespSuccess);
+ if(iCallbackOutstanding)
+ {
+ CHECK_NOERROR(iOwner.RequestCompleteIndicationCallback(resp));
+ }
+ }
+
+void CObexServerNotifySyncWrapper::SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo)
+ {
+ iCallbackOutstanding = ETrue;
+ TInt err = iNotify->SetPathIndication(aPathInfo, aInfo);
+ TObexResponse resp = IrOBEXUtil::ObexResponse(err, ERespSuccess);
+ if(iCallbackOutstanding)
+ {
+ CHECK_NOERROR(iOwner.RequestCompleteIndicationCallback(resp));
+ }
+ }
+
+void CObexServerNotifySyncWrapper::AbortIndication()
+ {
+ iNotify->AbortIndication();
+ }
+
+void CObexServerNotifySyncWrapper::CancelIndicationCallback()
+ {
+ //Appilcation may stop the obex server for whatever reason during an Indication
+ //thus resets the state machine. We have to make sure not to call indication
+ //callback in such cases because the statemachine will panic.
+ iCallbackOutstanding = EFalse;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexserverrequestpacketengine.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,47 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "obexserverrequestpacketengine.h"
+#include <obexserver.h>
+
+CObexServerRequestPacketEngine* CObexServerRequestPacketEngine::NewL(CObexServer& aServer)
+ {
+ CObexServerRequestPacketEngine* self = new (ELeave) CObexServerRequestPacketEngine(aServer);
+ return self;
+ }
+
+CObexServerRequestPacketEngine::~CObexServerRequestPacketEngine()
+ {
+
+ }
+
+CObexServerRequestPacketEngine::CObexServerRequestPacketEngine(CObexServer& aServer)
+ : iServer(aServer)
+ {
+
+ }
+
+void CObexServerRequestPacketEngine::SetObexServerRequestPacketObserver(MObexServerRequestPacketNotify& aRequestPacketNotify)
+ {
+ iRequestPacketNotify = &aRequestPacketNotify;
+ }
+
+void CObexServerRequestPacketEngine::DeleteObexServerRequestPacketNotifyRegister()
+ {
+ iServer.iServerRequestPacketEngine = NULL;
+ delete this;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexserverstatemachine.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,477 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <obex.h>
+#include <obex/internal/obexinternalheader.h>
+#include "obexserverstatemachine.h"
+
+#if ( defined __FLOG_ACTIVE && defined __LOG_FUNCTIONS__ )
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+/**
+@file
+@internalComponent
+*/
+
+/**
+Constructs the state machine and the state classes
+
+@param aOwner Server object that owns the state machine
+@param aTransport Transport Controller associated with the Server
+
+@return Contructed CObexServerStateMachine object
+*/
+CObexServerStateMachine* CObexServerStateMachine::NewL(CObexServer& aOwner, CObexTransportControllerBase& aTransport)
+ {
+ CObexServerStateMachine* self = new(ELeave) CObexServerStateMachine(aOwner, aTransport);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+First phase constructor
+
+@param aOwner Server object that owns the state machine
+@param aTransport Transport Controller associated with the Server
+*/
+CObexServerStateMachine::CObexServerStateMachine(CObexServer& aOwner, CObexTransportControllerBase& aTransport)
+ : iCurrentState(&iStates[EDisconnected]), iTransport(aTransport), iOwner(aOwner), iServerStarted(EFalse)
+ {
+ // Use placement new here to create the state objects and put them into a pre-defined array
+ // This is done as the number of states is known at compile time and this avoids heap fragmentation
+ new(&iStates[EDisconnected]) TObexServerStateDisconnected();
+ new(&iStates[ETransportConnected]) TObexServerStateTransportConnected();
+ new(&iStates[EObexConnecting]) TObexServerStateObexConnecting();
+ new(&iStates[EWaitForUserPassword]) TObexServerStateWaitForUserPassword();
+ new(&iStates[EReady]) TObexServerStateReady();
+ new(&iStates[EPutOpWaitForUser]) TObexServerStatePutOpWaitForUser();
+ new(&iStates[EPutOpReceiveObject]) TObexServerStatePutOpReceiveObject();
+ new(&iStates[EGetOpReceiveSpecification]) TObexServerStateGetOpReceiveSpecification();
+ new(&iStates[EGetOpWaitForUser]) TObexServerStateGetOpWaitForUser();
+ new(&iStates[EGetOpSendObject]) TObexServerStateGetOpSendObject();
+ new(&iStates[ESetPathOp]) TObexServerStateSetPathOp();
+ new(&iStates[EPutOpFinal]) TObexServerStatePutOpFinal();
+ new(&iStates[EGetOpFinal]) TObexServerStateGetOpFinal();
+ new(&iStates[EDisconnecting]) TObexServerStateDisconnecting();
+ }
+
+/**
+Second phase constructor
+*/
+void CObexServerStateMachine::ConstructL()
+ {
+ iSpecObject = CObexNullObject::NewL();
+ iHeader = CObexHeader::NewL();
+ iCallBack = new(ELeave) CAsyncCallBack(CActive::EPriorityStandard);
+ }
+
+/**
+Destructor
+*/
+CObexServerStateMachine::~CObexServerStateMachine()
+ {
+ // No need to delete state array
+ delete iHeader;
+ delete iSpecObject;
+ delete iPutFinalResponseHeaderSet;
+ delete iCallBack;
+ }
+
+/**
+Move machine to a new state
+Note that this function is synchronous, so any code after calling this function
+will be executed with the machine in a different state.
+Usually the action after changing state should be to return from the current function.
+
+@param aState Index of new state
+@return Result of state change
+*/
+void CObexServerStateMachine::ChangeState(TObexServerOperationStateEnum aState)
+ {
+ STATE_LOG_2(_L8("Changing from state %S to %S"), &iCurrentState->iName, &iStates[aState].iName);
+ iCurrentState = &(iStates[aState]);
+ iCurrentStateEnum = aState;
+ iCurrentState->Entry(*this);
+ }
+
+void CObexServerStateMachine::ControlledTransportDown()
+ {
+ LOG_FUNC
+
+ iOwner.ControlledTransportDown();
+ }
+
+/**
+Process a received packet according to the packet's op-code and the current state
+
+@param aPacket Packet to process
+@return Result of any state changes
+*/
+void CObexServerStateMachine::OnPacketReceive(CObexPacket& aPacket)
+ {
+ if (!iServerStarted)
+ {
+ __ASSERT_DEBUG(iServerStarted, IrOBEXUtil::Fault(EPacketReceivedWhenServerNotStarted));
+ return;
+ }
+
+ iLastReceivedPacket = &aPacket;
+
+ if(Transport().IsWriteActive())
+ {
+ FLOG(_L("OnPacketReceive received request whilst writing... dropping connection\r\n"));
+ Notification().ObexDisconnectIndication(KNullDesC8);
+ // change state before issuing the transport down, as it may cause notifications
+ ChangeState(ETransportConnected);
+ ControlledTransportDown();
+ return;
+ }
+
+ // Initialise the send packet to ensure that we do not
+ // accidentally send the same packet as last time!
+ iTransport.SendPacket().Init(0);
+
+ switch (aPacket.Opcode())
+ {
+ case CObex::EOpConnect:
+ STATE_LOG(_L8("Calling connect"));
+ iCurrentState->Connect(*this, aPacket);
+ break;
+ case CObex::EOpDisconnect:
+ STATE_LOG(_L8("Calling disconnect"));
+ iCurrentState->Disconnect(*this, aPacket);
+ break;
+ case CObex::EOpPut:
+ STATE_LOG(_L8("Calling put"));
+ iCurrentState->Put(*this, aPacket);
+ break;
+ case CObex::EOpGet:
+ STATE_LOG(_L8("Calling get"));
+ iCurrentState->Get(*this, aPacket);
+ break;
+ case CObex::EOpSetPath:
+ STATE_LOG(_L8("Calling SetPath"));
+ iCurrentState->SetPath(*this, aPacket);
+ break;
+ case CObex::EOpAbortNoFBit:
+ // Abort does not check target headers (hence no need to send the packet to the event)
+ STATE_LOG(_L8("Calling abort"));
+ iCurrentState->Abort(*this);
+ break;
+
+ default:
+ // Unknown packet type
+ STATE_LOG(_L8("Unknown packet type"));
+ iTransport.Send(ERespNotImplemented);
+ break;
+ }
+ }
+
+/**
+Indicates a transport-level connection has been made to the Server
+*/
+void CObexServerStateMachine::TransportUp()
+ {
+ // This event could happen while the Server is stopped (as the transport state
+ // can be independent of whether the Server has requested a read)
+ iCurrentState->TransportUp(*this);
+ }
+
+/**
+Indicates the transport-level connection to the Server has disappeared
+*/
+void CObexServerStateMachine::TransportDown()
+ {
+ // This event could happen while the Server is stopped (as the transport state
+ // can be independent of whether the Server has requested a read)
+ iCurrentState->Reset(*this);
+ }
+
+/**
+Indicates a Protocol Error has occurred
+*/
+void CObexServerStateMachine::Error()
+ {
+ // This event could happen while the Server is stopped (as the transport state
+ // can be independent of whether the Server has requested a read)
+ iCurrentState->Reset(*this);
+ }
+
+/**
+Process an OBEX object received as part of an asynchronous Put/Get indication
+This object pointer can be NULL to indicate an error condition
+@see MObexServerNotifyAsync::PutRequestInidication
+@see MObexServerNotifyAsync::GetRequestInidication
+@see CObexServer::RequestIndicationCallback
+
+@param aObject OBEX object to use (NULL to indication an error condition)
+@return Result of any state changes
+*/
+TInt CObexServerStateMachine::RequestNotificationCompleted(CObexBaseObject* aObject)
+ {
+ __ASSERT_ALWAYS(iCurrentStateEnum == EPutOpWaitForUser ||
+ iCurrentStateEnum == EGetOpWaitForUser, IrOBEXUtil::Panic(EInvalidResponseCallback));
+ if (!iServerStarted)
+ {
+ return KErrIrObexServerStopped;
+ }
+
+ iCurrentState->RequestNotificationCompleted(*this, aObject);
+ return KErrNone;
+ }
+
+/**
+Process the response received as part of an asynchronous PutComplete/GetComplete/SetPath indication
+
+@param aAppResponse Application's response to the indication
+@return result of state changes
+*/
+TInt CObexServerStateMachine::RequestNotificationCompleted(TObexResponse aAppResponse)
+ {
+ __ASSERT_ALWAYS(iCurrentStateEnum == EPutOpWaitForUser ||
+ iCurrentStateEnum == EGetOpWaitForUser, IrOBEXUtil::Panic(EInvalidResponseCallback));
+ __ASSERT_ALWAYS(iCurrentState->ValidResponse(aAppResponse), IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+ if (!iServerStarted)
+ {
+ return KErrIrObexServerStopped;
+ }
+
+ iCurrentState->RequestNotificationCompleted(*this, aAppResponse);
+ return KErrNone;
+ }
+
+/**
+Process the response received as part of an asynchronous PutComplete/GetComplete/SetPath indication
+
+@param aAppResponse Application's response to the indication
+@return result of state changes
+*/
+TInt CObexServerStateMachine::RequestCompleteNotificationCompleted(TObexResponse aAppResponse)
+ {
+ __ASSERT_ALWAYS(iCurrentStateEnum == ESetPathOp || iCurrentStateEnum == EGetOpFinal ||
+ iCurrentStateEnum == EPutOpFinal, IrOBEXUtil::Panic(EInvalidResponseCallback));
+ __ASSERT_ALWAYS(iCurrentState->ValidResponse(aAppResponse), IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp));
+ if (!iServerStarted)
+ {
+ return KErrIrObexServerStopped;
+ }
+
+ iCurrentState->RequestCompleteNotificationCompleted(*this, aAppResponse);
+ return KErrNone;
+ }
+
+/**
+Indicates an OBEX level connection has been established
+
+@return Result of any state changes
+*/
+void CObexServerStateMachine::ConnectionComplete()
+ {
+ __ASSERT_ALWAYS(iServerStarted, IrOBEXUtil::Fault(EConnectionCompleteWhenServerStopped));
+
+ iCurrentState->ConnectionComplete(*this);
+ }
+
+/**
+Indicates Server has been started
+
+@param aNotify Notification interface to use
+*/
+void CObexServerStateMachine::Start(MObexServerNotifyAsync& aNotify)
+ {
+ iServerStarted = ETrue;
+ iNotification = &aNotify; // state will panic if trying to change interface at an inappropriate point
+ iCurrentState->Start(*this);
+ }
+
+/**
+Indicates Server has been stopped
+*/
+void CObexServerStateMachine::Stop()
+ {
+ iCurrentState->Reset(*this);
+ iServerStarted = EFalse;
+ }
+
+/**
+Indication that the Obex server application has chosen to override the
+handling of the request packet that has been received.
+
+@param aResponse The response the server application has indicated that should
+ be sent to the Obex client. The actual sending of the response
+ is delegated to the individual states to handle as appropriate.
+@return Result of any state changes
+*/
+void CObexServerStateMachine::OverrideRequestHandling(TObexResponse aResponse)
+ {
+ iCurrentState->OverrideRequestHandling(*this, aResponse);
+ }
+
+/**
+Indicates that a write of a packet has been completed successfully at the
+transport level.
+*/
+void CObexServerStateMachine::WriteComplete()
+ {
+ LOG_FUNC
+
+ iCurrentState->WriteComplete(*this);
+ }
+
+/**
+Indicates that a new obex packet is being read.
+*/
+void CObexServerStateMachine::ReadActivityDetected()
+ {
+ LOG_FUNC
+
+ iCurrentState->ReadActivityDetected(*this);
+ }
+
+/**
+@return Last packet processed by the state machine
+*/
+CObexPacket& CObexServerStateMachine::LastReceivedPacket() const
+ {
+ __ASSERT_DEBUG(iLastReceivedPacket, IrOBEXUtil::Fault(ENoReceivePacketAvailable));
+ return *iLastReceivedPacket;
+ }
+
+/**
+This sets pointer of the object received from the application
+and so can be NULL to indicate an error
+
+@see CObexServerStateMachine::NotificationComplete
+@return Specification Object - used to describe the OBEX object to Get
+*/
+CObexBaseObject* CObexServerStateMachine::SpecObject() const
+ {
+ return iSpecObject;
+ }
+
+/**
+This returns pointer to the object received from the application
+and so can be NULL to indicate an error
+
+@see CObexServerStateMachine::NotificationComplete
+@return Transfer object to exchange with the Client
+*/
+CObexBaseObject* CObexServerStateMachine::TransObject() const
+ {
+ return iTransObject;
+ }
+
+/**
+@param aTransObject New transfer object to exchange with the Client
+*/
+void CObexServerStateMachine::SetTransObject(CObexBaseObject* aTransObject)
+ {
+ iTransObject = aTransObject;
+ }
+
+/**
+@return Transport Controller associated with the Server
+*/
+CObexTransportControllerBase& CObexServerStateMachine::Transport() const
+ {
+ return iTransport;
+ }
+
+/**
+@return Server object associated with the State Machine
+*/
+CObexServer& CObexServerStateMachine::Owner() const
+ {
+ return iOwner;
+ }
+
+/**
+@return Notification interface associated with the Server
+*/
+MObexServerNotifyAsync& CObexServerStateMachine::Notification() const
+ {
+ __ASSERT_DEBUG(iNotification, IrOBEXUtil::Fault(ENoNotifierAvailable));
+ return *iNotification;
+ }
+
+/**
+@return Final Header set to send at the end of a Put operation
+*/
+CObexHeaderSet* CObexServerStateMachine::PutFinalResponseHeaderSet()
+ {
+ return iPutFinalResponseHeaderSet;
+ }
+
+/**
+@param aHeaderSet Final Header set to send at the end of a Put operation
+*/
+void CObexServerStateMachine::SetPutFinalResponseHeaderSet(CObexHeaderSet* aHeaderSet)
+ {
+ delete iPutFinalResponseHeaderSet;
+ iPutFinalResponseHeaderSet = aHeaderSet;
+ }
+
+/**
+@return Internal header object (used for sizing the final response header set)
+*/
+CObexHeader* CObexServerStateMachine::GetHeader()
+ {
+ return iHeader;
+ }
+
+/**
+Activate one-shot call-back to run from the Active Scheduler
+@param aFunction Pointer to the function to call
+*/
+void CObexServerStateMachine::CallBack(TInt (*aFunction)(TAny* aPtr))
+ {
+ iCallBack->Set(TCallBack(aFunction, this));
+ iCallBack->CallBack();
+ }
+
+/**
+Cancel one-shot call-back
+*/
+void CObexServerStateMachine::CancelCallBack()
+ {
+ iCallBack->Cancel();
+ }
+
+/**
+@return If one-shot call-back is active
+*/
+TBool CObexServerStateMachine::IsCallBackActive() const
+ {
+ return iCallBack->IsActive();
+ }
+
+TObexResponse CObexServerStateMachine::AppResponse() const
+ {
+ return iAppResponse;
+ }
+
+void CObexServerStateMachine::SetAppResponse(TObexResponse aAppResponse)
+ {
+ __ASSERT_DEBUG(aAppResponse>0 && aAppResponse<=255, IrOBEXUtil::Panic(EInvalidResponseCodeFromServerApp ));
+
+ //remove the final bit, sorry about the horrible double casting.
+ aAppResponse = static_cast<TObexResponse>(static_cast<TInt> (aAppResponse) & 0x7F);
+ iAppResponse = aAppResponse;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexsetpathdata.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,54 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "obexsetpathdata.h"
+
+TObexSetPathData::TObexSetPathData ()
+ {
+ iFlags = 0;
+ iConstants = 0;
+ }
+
+TUint16 TObexSetPathData::DoTotalSize () const
+ {
+ return 2;
+ }
+
+TUint16 TObexSetPathData::ParseIn (TUint8* aSource, const TUint16 aMaxSize)
+ {
+ if (aMaxSize < TotalSize ())
+ {
+ return (0);
+ }
+ iFlags = aSource[0];
+ iConstants = aSource[1];
+ return (TotalSize ());
+ }
+
+TUint16 TObexSetPathData::WriteOut (TUint8* aDest, const TUint16 aMaxSize) const
+ {
+ if (aMaxSize < TotalSize ())
+ {
+ return (0);
+ }
+ aDest[0] = iFlags;
+ aDest[1] = iConstants;
+ return (TotalSize ());
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/src/obexsyncfilewriter.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,166 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <f32file.h>
+#include "obexsyncfilewriter.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEX");
+#endif
+
+//
+// Panic category for CObexSyncFileWriter
+//
+_LIT(KObexSyncFileWriterPanic, "Obex-SFW");
+
+/**
+Panic codes for CObexSyncFileWriter
+
+@internalComponent
+@released
+*/
+enum TSyncObexFileWriterPanic
+ {
+ /** Null buffer pointer */
+ ENullBufferPointer
+ };
+
+//
+// Implementation of CObexSyncFileWriter
+//
+
+/**
+Factory function
+
+Note that we return a pointer to the interface class, so
+that this class can only be used through this interface.
+This class in an implementation of a strategy as part of
+a Strategy pattern. CObexAsyncFileWriter provides an
+alternative strategy implementation, with CObexBufObject
+as the context for these strategies.
+
+@see MObexFileWriter
+@see CObexAsyncFileWriter
+@see CObexBufObject
+
+@internalComponent
+@released
+
+@param aFile The file we're writing to
+@return An MObexFileWriter for writing to file
+*/
+MObexFileWriter* CObexSyncFileWriter::NewL(RFile& aFile)
+ {
+ CObexSyncFileWriter* self = new(ELeave) CObexSyncFileWriter(aFile);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+Constructor
+
+@internalComponent
+@released
+
+@param aFile The file to write to
+*/
+CObexSyncFileWriter::CObexSyncFileWriter(RFile& aFile)
+ : iFile(aFile)
+ {
+ }
+
+/**
+2nd phase constructor
+
+@internalComponent
+@released
+*/
+void CObexSyncFileWriter::ConstructL()
+ {
+ }
+
+/**
+Normal write to file
+
+@internalComponent
+@released
+
+@param aPos The file position
+@param aBuf The buffer we're to write. We use this buffer by copying the pointer
+ and return the buffer we previously wrote to the caller by updating
+ the pointer. If an error occurs, the buffers are not swapped and
+ the pointer is not updated. Note that this class never owns any
+ buffers and that passing a buffer to this function does not imply a
+ transfer of ownership.
+@return Symbian OS error code
+*/
+TInt CObexSyncFileWriter::Write(TInt aPos, CBufBase*& aBuf)
+ {
+ __ASSERT_ALWAYS(aBuf, PANIC(KObexSyncFileWriterPanic, ENullBufferPointer));
+
+ // Write the next block
+ return iFile.Write(aPos, aBuf->Ptr(0));
+ }
+
+/**
+Final, synchronous write to file
+
+@internalComponent
+@released
+
+@param aPos The file position
+@param aBuf The buffer we're to write. We use this buffer by copying the pointer
+ and return the buffer we previously wrote to the caller by updating
+ the pointer. If an error occurs, the buffers are not swapped and
+ the pointer is not updated. Note that this class never owns any
+ buffers and that passing a buffer to this function does not imply a
+ transfer of ownership.
+@param aLength The amount of the buffer to write
+@return Symbian OS error code
+*/
+TInt CObexSyncFileWriter::FinalWrite(TInt aPos, CBufBase*& aBuf, TInt aLength)
+ {
+ __ASSERT_ALWAYS(aBuf, PANIC(KObexSyncFileWriterPanic, ENullBufferPointer));
+
+ // Write the final block
+ TInt err = iFile.Write(aPos, aBuf->Ptr(0), aLength);
+ if (err == KErrNone)
+ {
+ //flush the buffer, commit the write
+ return iFile.Flush();
+ }
+ else
+ {
+ return err;
+ }
+ }
+
+/**
+Destructor
+
+@internalComponent
+@released
+*/
+CObexSyncFileWriter::~CObexSyncFileWriter()
+ {
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/group/t_obexheadercheck.mmp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,50 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Pointless file produced by test project; the test is that it
+// compiles at all.
+//
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+target t_obexheadercheck.exe
+targettype exe
+uid 0
+VENDORID 0x70000001
+
+sourcepath ../src
+source main.cpp
+source t_obex.cpp
+source t_obexbase.cpp
+source t_obexbaseobject.cpp
+source t_obexclient.cpp
+source t_obexconstants.cpp
+source t_obexheaders.cpp
+source t_obexobjects.cpp
+source t_obexserver.cpp
+source t_obextypes.cpp
+source t_obexfinalpacketobserver.cpp
+source t_ObexTransportInfo.cpp
+source t_ObexIrTransportInfo.cpp
+source t_ObexBtTransportInfo.cpp
+source t_ObexUsbTransportInfo.cpp
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+library euser.lib
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/main.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,21 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32std.h>
+
+GLDEF_C TInt E32Main()
+ {
+ return KErrNone;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_ObexBtTransportInfo.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexbttransportinfo.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_ObexIrTransportInfo.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexirtransportinfo.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_ObexTransportInfo.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obextransportinfo.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_ObexUsbTransportInfo.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexusbtransportinfo.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obex.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexbase.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexbase.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexbaseobject.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexbaseobject.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexclient.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexclient.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexconstants.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexconstants.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexfinalpacketobserver.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexfinalpacketobserver.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexheaders.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexheaders.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexobjects.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexobjects.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obexserver.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexserver.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/headercheck/src/t_obextypes.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obextypes.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodes.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,348 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <c32comm.h>
+#include "TestObexErrorCodes.h"
+
+#if defined (__WINS__)
+#define PDD_NAME _L("ECDRV")
+#define LDD_NAME _L("ECOMM")
+#else // __GCC32__
+#define PDD_NAME _L("EUART2")
+#define LDD_NAME _L("ECOMM")
+#define FIR_PDD_NAME _L("DIFIR") // Brutus FIR PDD
+#define FIR_LDD_NAME _L("EFIR") // Brutus FIR LDD
+#endif
+
+
+
+void Startup()
+ {
+ CActiveScheduler *pA=new CActiveScheduler;
+ CActiveScheduler::Install(pA);
+
+ CControllerTestMasterClass* bigBoss = CControllerTestMasterClass::NewL();
+
+ CActiveScheduler::Start();
+ delete bigBoss;
+ bigBoss = NULL;
+ delete pA;
+ }
+
+
+void CControllerTestMasterClass::ConstructL()
+ {
+ //make the initial active object everything
+ iConsoleTest = CControllerConsoleTest::NewL(this);
+
+ iConsoleTest->IssueRequest();
+
+ }
+
+CControllerTestMasterClass* CControllerTestMasterClass::NewL()
+ {
+ CControllerTestMasterClass* self = NewLC();
+ CleanupStack::Pop();
+ return self;
+ }
+
+CControllerTestMasterClass* CControllerTestMasterClass::NewLC()
+ {
+ CControllerTestMasterClass* self=new (ELeave) CControllerTestMasterClass;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+
+
+CControllerTestMasterClass::~CControllerTestMasterClass()
+ {
+ delete iConsoleTest;
+ iConsoleTest = NULL;
+ }
+
+
+
+GLDEF_C TInt E32Main()
+ {
+
+ __UHEAP_MARK;
+ CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
+
+
+ // start scheduler
+ TRAPD(error, Startup() );
+ __ASSERT_ALWAYS(!error,User::Panic(_L("Testing Registry"),error));
+
+
+ delete cleanup; // destroy clean-up stack
+ __UHEAP_MARKEND;
+ return KErrNone;
+ }
+
+
+
+//
+// CRegistryConsoleTest
+//
+CControllerConsoleTest::~CControllerConsoleTest()
+ {
+ Cancel();
+
+
+ delete iTest;
+ delete iConsole;
+ iConsole = NULL;
+ iOwner = NULL;
+
+ }
+
+
+void CControllerConsoleTest::DoCancel()
+ {
+ iConsole->ReadCancel();
+ }
+
+
+void CControllerConsoleTest::Menu()
+ {
+ iConsole->Printf(_L("\nOBEX error code tests ..."));
+ iConsole->Printf(_L("\nPress '1' to start Client Side Tests"));
+ iConsole->Printf(_L("\nPress '2' to start Server Side Tests"));
+ iConsole->Printf(_L("\nPress '3' to start"));
+ iConsole->Printf(_L("\nPress '4' to stop"));
+ iConsole->Printf(_L("\nAny other key to exit"));
+ }
+
+void CControllerConsoleTest::IssueRequest()
+ {
+ Menu();
+ iConsole->Read(iStatus);
+ SetActive();
+ }
+void CControllerConsoleTest::ConstructL(CControllerTestMasterClass* aOwner)
+ {
+
+ iOwner = aOwner;
+ iConsole = Console::NewL(_L("Controller Test"),
+ TSize(-1,-1));
+ DoTest(); //set everything up, load everything
+
+
+ CActiveScheduler::Add(this);
+ }
+
+TInt CControllerConsoleTest::RunError(TInt)
+ {
+ IssueRequest();
+ return KErrNone;
+ }
+
+
+void CControllerConsoleTest::StartTest()
+ {
+ iTest->Start();
+
+ iStarted = ETrue;
+
+ }
+
+void CControllerConsoleTest::StopTest()
+ {
+
+ if ( iStarted )
+ {
+ iTest->Stop();
+
+ iStarted = EFalse;
+ }
+ else
+ {
+ iConsole->Printf(_L("DOOH, can't stop a test which hasn't started\n"));
+ }
+ }
+
+void CControllerConsoleTest::DoTest()
+ {
+ iStarted = EFalse;
+ iConsole->Printf(_L("\n Loading tests"));
+
+
+
+ TInt ret;
+#ifdef __EPOC32__
+ iConsole->Printf(_L("Loading C32...\n"));
+ ret=StartC32();
+ if (ret!=KErrNone && ret!=KErrAlreadyExists)
+ iConsole->Printf(_L(" Failed %d\n"), ret);
+ else
+ iConsole->Printf(_L(" Success\n"));
+#endif
+
+// load up the drivers
+ iConsole->Printf(_L("Loading SIR PDD...\n"));
+ ret=User::LoadPhysicalDevice(PDD_NAME);
+ if (ret!=KErrNone && ret!=KErrAlreadyExists)
+ iConsole->Printf(_L(" Failed %d\n"), ret);
+ else
+ iConsole->Printf(_L(" Success\n"));
+
+ iConsole->Printf(_L("Loading SIR LDD...\n"));
+ ret=User::LoadLogicalDevice(LDD_NAME);
+ if (ret!=KErrNone && ret!=KErrAlreadyExists)
+ iConsole->Printf(_L(" Failed %d\n"), ret);
+ else
+ iConsole->Printf(_L(" Success\n"));
+#ifdef __EPOC32__
+ iConsole->Printf(_L("Loading Fast IR PDD\n"));
+
+ ret=User::LoadPhysicalDevice(FIR_PDD_NAME);
+ if (ret!=KErrNone && ret!=KErrAlreadyExists)
+ iConsole->Printf(_L(" Failed %d\n"), ret);
+ else
+ iConsole->Printf(_L(" Success\n"));
+
+ iConsole->Printf(_L("Loading Fast IR LDD\n"));
+ ret=User::LoadLogicalDevice(FIR_LDD_NAME);
+ if (ret!=KErrNone && ret!=KErrAlreadyExists)
+ iConsole->Printf(_L(" Failed %d\n"), ret);
+ else
+ iConsole->Printf(_L(" Success\n"));
+#endif
+
+
+ }
+
+
+void CControllerConsoleTest::RunL()
+ {
+
+ TInt key = iConsole->KeyCode();
+ switch (key)
+ {
+ case '1':
+ {
+ iTest = CTestObexErrorCodesClient::NewL(this);
+ IssueRequest(); //back to main menu
+ }
+ break;
+ case '2':
+ {
+ iTest = CTestObexErrorCodesServer::NewL(this);
+ IssueRequest(); //back to main menu
+ }
+ break;
+ case '3':
+ {
+ if ( !iStarted )
+ StartTest();
+ else
+ iConsole->Printf(_L("Already Started\n"));
+
+ IssueRequest(); //back to main menu
+
+ }
+ break;
+ case '4':
+ {
+ if ( iStarted )
+ StopTest();
+ else
+ iConsole->Printf(_L("Not started yet\n"));
+
+ IssueRequest(); //back to main menu
+ }
+ break;
+ default:
+ CActiveScheduler::Stop();
+ break;
+ }
+
+ }
+
+
+CControllerConsoleTest* CControllerConsoleTest::NewL(CControllerTestMasterClass* aOwner)
+ {
+ CControllerConsoleTest* self = NewLC(aOwner);
+ CleanupStack::Pop();
+ return self;
+ }
+
+CControllerConsoleTest* CControllerConsoleTest::NewLC(CControllerTestMasterClass* aOwner)
+ {
+ CControllerConsoleTest* self=new (ELeave) CControllerConsoleTest;
+ CleanupStack::PushL(self);
+ self->ConstructL(aOwner);
+ return self;
+
+ }
+
+CControllerConsoleTest::CControllerConsoleTest()
+ : CActive(CActive::EPriorityStandard)
+ {
+ }
+
+
+
+
+
+CBaseErrorCodeTest* CBaseErrorCodeTest::NewL(CControllerConsoleTest* aOwner)
+ {
+ CBaseErrorCodeTest* self = new(ELeave) CBaseErrorCodeTest;
+ CleanupStack::PushL(self);
+ self->ConstructL(aOwner);
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+CBaseErrorCodeTest::~CBaseErrorCodeTest()
+ {
+ delete iObject;
+ delete iBuf;
+ iLibrary.Close();
+ }
+
+
+CBaseErrorCodeTest::CBaseErrorCodeTest()
+ {
+ }
+
+void CBaseErrorCodeTest::ConstructL(CControllerConsoleTest* aOwner)
+ {
+ iOwner = aOwner;
+
+ iOwner->iConsole->Printf(_L("About to load the IRObex DLL...\n"));
+
+
+ TRAPD(ret,LoadObexL()); // Load Protocol
+ if (ret!=KErrNone)
+ iOwner->iConsole->Printf(_L("Error %d on loading IrObex DLL\r\n"),ret);
+ else
+ iOwner->iConsole->Printf(_L("Successfully loaded IrObex DLL\r\n"));
+ }
+
+void CBaseErrorCodeTest::LoadObexL()
+ {
+ User::LeaveIfError(iLibrary.Load(_L("IROBEX.DLL")));
+ }
+
+void CBaseErrorCodeTest::Start()
+ {
+ }
+
+void CBaseErrorCodeTest::Stop()
+ {
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodes.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,209 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __TESTOBEXERRORCODES_H__
+#define __TESTOBEXERRORCODES_H__
+
+#include <e32cons.h>
+#include <e32def.h>
+#include <e32std.h>
+#include <e32base.h>
+#include <obex.h>
+
+class CControllerConsoleTest;
+class CBaseErrorCodeTest;
+class CObexClientHandler;
+
+enum TTestProgress { EIdle, EConnecting, EDisconnecting, EConnected, EPutting };
+
+class CControllerTestMasterClass : CBase
+ {
+public:
+ void ConstructL();
+ static CControllerTestMasterClass* NewL();
+ static CControllerTestMasterClass* NewLC();
+ ~CControllerTestMasterClass();
+
+public:
+ CControllerConsoleTest* iConsoleTest;
+ };
+
+
+
+class CControllerConsoleTest : CActive
+ {
+
+public:
+ void ConstructL(CControllerTestMasterClass*);
+ static CControllerConsoleTest* NewL(CControllerTestMasterClass*);
+ static CControllerConsoleTest* NewLC(CControllerTestMasterClass*);
+ ~CControllerConsoleTest();
+public:
+ void IssueRequest();
+ void DoCancel();
+ void RunL();
+ void TestAll();
+ TInt RunError(TInt);
+ void DoTest();
+
+private:
+ CControllerConsoleTest();
+ void StartTest();
+ void StopTest();
+ void Menu();
+private:
+ CControllerTestMasterClass* iOwner;
+
+public:
+ CConsoleBase* iConsole;
+ CBaseErrorCodeTest* iTest;
+ TBool iStarted;
+ };
+
+
+
+class CBaseErrorCodeTest : public CBase
+ {
+public:
+ static CBaseErrorCodeTest* NewL(CControllerConsoleTest* aOwner);
+ virtual ~CBaseErrorCodeTest();
+
+public:
+
+ virtual void Start();
+ virtual void Stop();
+
+
+protected:
+
+ CBaseErrorCodeTest();
+ void ConstructL(CControllerConsoleTest* aOwner);
+ void LoadObexL();
+
+public:
+ CControllerConsoleTest* iOwner;
+
+
+
+protected:
+ CObexBufObject* iObject;
+ CBufFlat *iBuf;
+ RLibrary iLibrary; // Use RLibrary object to interface to the DLL
+ TInt iErrorCode;
+ };
+
+/**
+*
+* The public API for Server test
+*
+*/
+
+class CTestObexErrorCodesServer : public CBaseErrorCodeTest, MObexServerNotify
+ {
+public:
+ static CTestObexErrorCodesServer* NewL(CControllerConsoleTest* aOwner);
+ virtual ~CTestObexErrorCodesServer();
+ void StartIrdaServerL();
+
+public:
+
+ virtual void Start();
+ virtual void Stop();
+
+
+private:
+ CTestObexErrorCodesServer();
+
+
+ // Virtual functions from OBEX
+ virtual void ErrorIndication(TInt aError);
+ virtual void TransportUpIndication();
+ virtual void TransportDownIndication();
+ virtual TInt ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo);
+ virtual void ObexDisconnectIndication(const TDesC8& aInfo);
+ virtual CObexBufObject* PutRequestIndication();
+ virtual TInt PutPacketIndication();
+ virtual TInt PutCompleteIndication();
+ virtual CObexBufObject* GetRequestIndication(CObexBaseObject *aRequiredObject);
+ virtual TInt GetPacketIndication();
+ virtual TInt GetCompleteIndication();
+ virtual TInt SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo);
+ virtual void AbortIndication();
+
+private:
+ CObexServer* iServer;
+ };
+
+/**
+*
+* The public API for Server test
+*
+*/
+
+class CTestObexErrorCodesClient : public CBaseErrorCodeTest
+ {
+public:
+ static CTestObexErrorCodesClient* NewL(CControllerConsoleTest* aOwner);
+ virtual ~CTestObexErrorCodesClient();
+ void StartIrdaClientL();
+ void ActionComplete(TObexResponse aResponse);
+
+public:
+ void CallBack(TRequestStatus aStatus, TTestProgress aActivity);
+ virtual void Start();
+ virtual void Stop();
+
+
+private:
+ CTestObexErrorCodesClient();
+
+private:
+ CObexClientHandler* iClient;
+ };
+
+
+
+class CObexClientHandler : public CActive
+ {
+public:
+ static CObexClientHandler* NewL(CTestObexErrorCodesClient* aOwner,
+ TObexProtocolInfo& aObexProtocolInfoPtr);
+ ~CObexClientHandler();
+
+public:
+ void Connect();
+ void Disconnect();
+ void Put();
+
+private:
+
+ CObexClientHandler();
+ void ConstructL(CTestObexErrorCodesClient* aOwner,
+ TObexProtocolInfo& aObexProtocolInfoPtr);
+
+ void DoCancel();
+ void RunL();
+
+
+
+private:
+ CObexClient* iClient;
+ CTestObexErrorCodesClient* iOwner;
+ TTestProgress iActivity;
+ CObexFileObject* iFileObject;
+
+ };
+
+#endif // __TESTOBEXERRORCODES_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodes.mmp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,50 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+*/
+
+TARGET testobexerrorcodes.exe
+TARGETTYPE exe
+
+
+SOURCEPATH .
+
+SOURCE TestObexErrorCodesServer.cpp TestObexErrorCodes.cpp TestObexErrorCodesClient.cpp
+
+
+USERINCLUDE .
+
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+#ifdef __OMAP__
+SYSTEMINCLUDE /epoc32/include/Kernel
+
+#endif //__OMAP__
+
+
+LIBRARY euser.lib irobex.lib irda.lib esock.lib efsrv.lib
+
+#ifndef WINS
+LIBRARY c32.lib
+#endif
+
+//
+
+VENDORID 0x70000001
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodesClient.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,237 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <f32file.h>
+#include "TestObexErrorCodes.h"
+
+/**
+ * Static NewL
+ *
+ * @return Base class*
+ */
+CTestObexErrorCodesClient* CTestObexErrorCodesClient::NewL(CControllerConsoleTest* aOwner)
+ {
+ CTestObexErrorCodesClient* self = new(ELeave) CTestObexErrorCodesClient;
+ CleanupStack::PushL(self);
+ self->ConstructL(aOwner);
+ self->StartIrdaClientL();
+ CleanupStack::Pop( self );
+
+ return self;
+ }
+
+
+
+
+/**
+*
+* CTestObexErrorCodesClient
+*
+*/
+
+CTestObexErrorCodesClient::CTestObexErrorCodesClient()
+ {
+ }
+
+/**
+*
+* ~CTestObexErrorCodesClient
+*
+*/
+
+CTestObexErrorCodesClient::~CTestObexErrorCodesClient()
+ {
+ delete iClient;
+ }
+
+void CTestObexErrorCodesClient::Stop()
+ {
+ iOwner->iConsole->Printf(_L("About to Stop the iClient ..\n"));
+
+
+ }
+
+
+void CTestObexErrorCodesClient::Start()
+ {
+//Start the test
+
+ iClient->Connect(); //should fail with appropriate error code
+
+
+ }
+
+
+
+
+void CTestObexErrorCodesClient::StartIrdaClientL()
+ {
+
+ iOwner->iConsole->Printf(_L("About to load the CObexClient...\n"));
+
+ TObexIrProtocolInfo aInfo;
+ aInfo.iTransport = _L("IrTinyTP");
+ aInfo.iClassName = _L8("OBEX");
+ aInfo.iAttributeName = _L8("IrDA:TinyTP:LsapSel");
+
+
+ iClient = CObexClientHandler::NewL (this, aInfo);
+
+
+ iBuf = CBufFlat::NewL(5000);//5000 - what should I put??
+ iObject = CObexBufObject::NewL (iBuf);
+ iOwner->iConsole->Printf(_L("Irda Client loaded Success \n"));
+
+
+
+ }
+
+void CTestObexErrorCodesClient::CallBack(TRequestStatus aStatus, TTestProgress aActivity)
+ {
+
+ //first of all establish what has just happened.
+ if ( aActivity == EConnecting ) //then it's time for the first PUT
+ {
+ iClient->Put();
+ iErrorCode = ERespContinue;
+ }
+ else if (aActivity == EPutting )
+ {
+ iOwner->iConsole->Printf(_L("Put Complete with Code %d \n"), aStatus.Int());
+ if ( iErrorCode < ERespDatabaseLocked )
+ {
+ iErrorCode++;
+ iClient->Put();
+ }
+ }
+
+ }
+
+
+
+
+CObexClientHandler* CObexClientHandler::NewL(CTestObexErrorCodesClient* aOwner,
+ TObexProtocolInfo& aObexProtocolInfoPtr)
+ {
+ CObexClientHandler* self = new(ELeave) CObexClientHandler;
+ CleanupStack::PushL(self);
+ self->ConstructL(aOwner, aObexProtocolInfoPtr);
+ CleanupStack::Pop( self );
+
+ return self;
+
+ }
+
+CObexClientHandler::~CObexClientHandler()
+ {
+ delete iClient;
+ }
+
+void CObexClientHandler::Connect()
+ {
+ if (!IsActive() )
+ {
+ iActivity = EConnecting;
+
+ iClient->Connect(iStatus);
+ SetActive();
+ }
+ else
+ iOwner->iOwner->iConsole->Printf(_L("\r\nError: Client handler already active\r\n"));
+ }
+
+void CObexClientHandler::Disconnect()
+ {
+ if (!IsActive() )
+ {
+ iActivity = EDisconnecting;
+ iClient->Disconnect(iStatus);
+ SetActive();
+ }
+ else
+ iOwner->iOwner->iConsole->Printf(_L("\r\nError: Client handler already active\r\n"));
+
+ }
+
+CObexClientHandler::CObexClientHandler()
+ : CActive(EPriorityNormal)
+ {
+ }
+
+void CObexClientHandler::ConstructL(CTestObexErrorCodesClient* aOwner,
+ TObexProtocolInfo& aObexProtocolInfoPtr)
+ {
+ iOwner = aOwner;
+
+ iFileObject = CObexFileObject::NewL();
+
+
+ iClient = CObexClient::NewL(aObexProtocolInfoPtr);
+ CActiveScheduler::Add(this); // Add to active scheduler
+ iActivity = EIdle;
+ }
+
+void CObexClientHandler::DoCancel()
+ {
+ iClient->Abort();
+ }
+
+void CObexClientHandler::RunL()
+ {
+
+ iOwner->CallBack(iStatus, iActivity);
+
+ }
+
+void CObexClientHandler::Put()
+ {
+ if(IsActive())
+ {
+
+ iOwner->iOwner->iConsole->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ TInt err;
+
+ TRAP(err, iFileObject->InitFromFileL (_L("Contacts.vcf")));
+
+ if (err != KErrNone)
+ {
+ RFs fs;
+ RFile f;
+ if ((fs.Connect () != KErrNone) ||
+ (f.Create (fs, _L("Contacts.vcf"), EFileShareExclusive | EFileWrite) != KErrNone))
+ iOwner->iOwner->iConsole->Printf(_L("\r\nError reading 'Contacts.vcf'.\r\nI tried to create this file for you, but failed to do that too. Sorry.\r\n\r\n"));
+ else
+ {
+ f.Write (_L8("Test file for sending from EPOC\r\n\r\nLooks like obex is sending OK!!\r\n"));
+ f.Close ();
+ iOwner->iOwner->iConsole->Printf(_L("\r\nFile 'Contacts.vcf' did not exist, so I've created one.\r\nPlease try again.\r\n\r\n"));
+ }
+ fs.Close ();
+ }
+
+
+ if( err != KErrNone)
+ {
+ iOwner->iOwner->iConsole->Printf(_L("\r\n Couldnt set up object : error %d \r\n"),err);
+ return;
+ }
+
+ iClient->Put(*iFileObject,iStatus);
+ SetActive();
+ iActivity = EPutting;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/testobexerrorcodes/TestObexErrorCodesServer.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,200 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "TestObexErrorCodes.h"
+
+/**
+ * Static NewL
+ *
+ * @return Base class*
+ */
+CTestObexErrorCodesServer* CTestObexErrorCodesServer::NewL(CControllerConsoleTest* aOwner)
+ {
+ CTestObexErrorCodesServer* self = new(ELeave) CTestObexErrorCodesServer;
+ CleanupStack::PushL(self);
+ self->ConstructL(aOwner);
+ self->StartIrdaServerL();
+ CleanupStack::Pop( self );
+
+ return self;
+ }
+
+
+
+
+/**
+*
+* CTestObexErrorCodesServer
+*
+*/
+
+CTestObexErrorCodesServer::CTestObexErrorCodesServer()
+ {
+ }
+
+/**
+*
+* ~CTestObexErrorCodesServer
+*
+*/
+
+CTestObexErrorCodesServer::~CTestObexErrorCodesServer()
+ {
+ delete iServer;
+ }
+
+void CTestObexErrorCodesServer::Stop()
+ {
+ iOwner->iConsole->Printf(_L("About to Stop the iServer ..\n"));
+
+ if(iServer)
+ iServer->Stop();
+ iOwner->iConsole->Printf(_L("iServer Stopped ..\n"));
+
+ }
+
+
+void CTestObexErrorCodesServer::Start()
+ {
+
+ iOwner->iConsole->Printf(_L("About to Start the iServer ..\n"));
+
+ TInt err = iServer->Start (this);
+ iOwner->iConsole->Printf(_L("Server started with err=%d ..\n"), err);
+
+ iErrorCode = ERespSuccess; //first returned code not Continue as this really breaks everything
+ }
+
+
+/**
+Virtual functions from OBEX
+*/
+
+void CTestObexErrorCodesServer::ErrorIndication(TInt /*aError*/)
+ {
+ }
+
+void CTestObexErrorCodesServer::TransportUpIndication()
+ {
+ iOwner->iConsole->Printf(_L("Transport layer now connected\n"));
+ }
+
+void CTestObexErrorCodesServer::TransportDownIndication()
+ {
+ iOwner->iConsole->Printf(_L("Transport layer has gone down\n"));
+ }
+
+TInt CTestObexErrorCodesServer::ObexConnectIndication(const TObexConnectInfo& /*aRemoteInfo*/, const TDesC8& /*aInfo*/)
+ {
+ return KErrNone;
+ }
+
+void CTestObexErrorCodesServer::ObexDisconnectIndication(const TDesC8& /*aInfo*/)
+ {
+ iOwner->iConsole->Printf(_L("\r\nObex Disconnected\n"));
+ }
+
+CObexBufObject* CTestObexErrorCodesServer::PutRequestIndication()
+ {
+ return (iObject);
+ }
+
+TInt CTestObexErrorCodesServer::PutPacketIndication()
+ {
+ return (KErrNone);
+
+ }
+
+TInt CTestObexErrorCodesServer::PutCompleteIndication()
+ {
+
+ iOwner->iConsole->Printf(_L("PutComplete returning error code %d ..\n"), iErrorCode);
+ //return the changing error code here
+ TInt retValue = (iErrorCode * -1 ) + KErrIrObexRespBase;
+
+ iErrorCode++;
+
+ return (retValue);
+// return (KErrNone);
+
+ }
+
+CObexBufObject* CTestObexErrorCodesServer::GetRequestIndication(CObexBaseObject* /*aRequiredObject*/)
+ {
+ return (NULL);
+ }
+
+TInt CTestObexErrorCodesServer::GetPacketIndication()
+ {
+ //return the changing error code here
+ TInt retValue = iErrorCode;
+ if ( iErrorCode < ERespDatabaseLocked )
+ iErrorCode++;
+ else
+ iErrorCode = ERespContinue;
+
+ return (retValue);
+ }
+
+TInt CTestObexErrorCodesServer::GetCompleteIndication()
+ {
+ //return the changing error code here
+ TInt retValue = iErrorCode;
+ if ( iErrorCode < ERespDatabaseLocked )
+ iErrorCode++;
+ else
+ iErrorCode = ERespContinue;
+
+ return (retValue);
+ }
+
+TInt CTestObexErrorCodesServer::SetPathIndication(const CObex::TSetPathInfo& /*aPathInfo*/, const TDesC8& /*aInfo*/)
+ {
+ //return the changing error code here
+ TInt retValue = iErrorCode;
+ if ( iErrorCode < ERespDatabaseLocked )
+ iErrorCode++;
+ else
+ iErrorCode = ERespContinue;
+
+ return (retValue);
+ }
+
+void CTestObexErrorCodesServer::AbortIndication()
+ {
+ }
+
+
+void CTestObexErrorCodesServer::StartIrdaServerL()
+ {
+
+ iOwner->iConsole->Printf(_L("About to load the CObexServer...\n"));
+
+ TObexIrProtocolInfo aInfo;
+ aInfo.iAddr.SetPort(9);//default obex server for now
+ aInfo.iTransport = _L("IrTinyTP");
+ aInfo.iClassName = _L8("OBEX");
+ aInfo.iAttributeName = _L8("IrDA:TinyTP:LsapSel");
+
+
+ iServer = CObexServer::NewL (aInfo);
+
+
+ iBuf = CBufFlat::NewL(5000);//5000 - what should I put??
+ iObject = CObexBufObject::NewL (iBuf);
+ iOwner->iConsole->Printf(_L("Irda Server loaded Success \n"));
+
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/Contactsbak.vcf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,7 @@
+BEGIN:VCARD
+VERSION:2.1
+REV:20020312T103257Z
+UID:1000118a25d0b113-e079ae8022476c-158
+ADR;WORK:;;3 Ely Road;Milton;Cambridgeshire;CB4 6AA;UK
+ORG:Symbian Cambridge;
+END:VCARD
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/Contactsbak2.vcf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,7 @@
+BEGIN:VCARD
+VERSION:2.1
+REV:20020312T103555Z
+UID:1000118a25d0b113-e079ae8b82cce4-159
+ADR;WORK:;;2-6 Boundary Row;Southwark;London;SE1 8HP;UK
+ORG:Symbian International Headquarters;
+END:VCARD
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/Contactsbak3.vcf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,7 @@
+BEGIN:VCARD
+VERSION:2.1
+REV:20020312T103832Z
+UID:1000118a25d0b113-e079ae94deab2d-160
+ADR;WORK:;;Soft Center;Ronneby;;SE-372 25;Sweden
+ORG:Symbian Ronneby;
+END:VCARD
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TOBEX.CPP Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,93 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <c32comm.h>
+#include "TOBEXCON.H"
+
+#ifdef __EPOC32__
+#define FIR_PDD_NAME _L("DIFIR") // Brutus FIR PDD
+#define FIR_LDD_NAME _L("EFIR") // Brutus FIR LDD
+#endif
+
+#ifdef __WINS__
+_LIT(KWinsPddName,"ecdrv");
+_LIT(KWinsLddName,"ecomm");
+#endif //__WINS__
+
+void RunAppL(void)
+ {
+ // Construct and install the active scheduler
+ CActiveScheduler *exampleScheduler = new (ELeave) CActiveScheduler();
+ // Push onto the cleanup stack
+ CleanupStack::PushL(exampleScheduler);
+ // Install as the active scheduler
+ CActiveScheduler::Install(exampleScheduler);
+ //Create Obex objects and console handler
+ CConsoleBase* aConsole =
+ //Console::NewL(_L("OBEX DLL Test Code"),TSize(20,10));
+ Console::NewL(_L("OBEX DLL Test Code"),TSize(KConsFullScreen,KConsFullScreen));
+ // Load Device drivers
+
+#ifdef __EPOC32__
+ TInt ret1;
+ aConsole->Printf(_L("Loading C32...\n"));
+ ret1=StartC32();
+ if (ret1!=KErrNone && ret1!=KErrAlreadyExists)
+ aConsole->Printf(_L(" Failed %d\n"), ret1);
+ else
+ aConsole->Printf(_L(" Sucess\n"));
+#endif
+#ifdef __WINS__
+ User::LoadLogicalDevice(KWinsLddName);
+ User::LoadPhysicalDevice(KWinsPddName);
+#endif //__WINS__
+
+#ifdef __EPOC32__
+ TInt ret2;
+
+ aConsole->Printf(_L("Loading Fast IR PDD\n"));
+
+ ret2=User::LoadPhysicalDevice(FIR_PDD_NAME);
+ if (ret2!=KErrNone && ret2!=KErrAlreadyExists)
+ aConsole->Printf(_L(" Failed %d\n"), ret2);
+ else
+ aConsole->Printf(_L(" Sucess\n"));
+
+ aConsole->Printf(_L("Loading Fast IR LDD\n"));
+ ret2=User::LoadLogicalDevice(FIR_LDD_NAME);
+ if (ret2!=KErrNone && ret2!=KErrAlreadyExists)
+ aConsole->Printf(_L(" Failed %d\n"), ret2);
+ else
+ aConsole->Printf(_L(" Success\n"));
+#endif
+
+ CleanupStack::PushL(aConsole);
+ CActiveConsole* my_console = CActiveConsole::NewLC(aConsole);
+ my_console->RequestCharacter();
+ CActiveScheduler::Start();
+ CleanupStack::PopAndDestroy(3);
+ }
+
+TInt E32Main()
+ {
+ __UHEAP_MARK;
+ CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
+ TRAPD(error,RunAppL()); // more initialization, then do example
+ __ASSERT_ALWAYS(!error,User::Panic(_L("TOBEX"),error));
+ delete cleanup; // destroy clean-up stack
+ __UHEAP_MARKEND;
+
+ return 0; // and return
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TOBEX.MMP Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,83 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+*/
+
+TARGET tobex.exe
+TARGETTYPE exe
+
+UID 0x0 0x1020e1a4
+
+CAPABILITY All -Tcb
+
+#define OBEX_EXTENSION_APIS //comment this out if the extension api is not present.
+//#define VERIFY_EMPTY_HEADERS_ACC //uncomment this is if you want to build the test code for checking the acceptance of OBEX requests containing empty headers
+
+SOURCEPATH .
+SOURCE TOBEX.CPP
+SOURCE TOBEXCON.CPP
+SOURCE btutils.cpp
+SOURCE clienthandler.cpp
+SOURCE serverhandlerbase.cpp
+SOURCE serverhandler.cpp
+SOURCE serverhandlerfile.cpp
+SOURCE TREFHANDLER.CPP
+SOURCE serverasyncao.cpp
+
+#ifdef VERIFY_EMPTY_HEADERS_ACC
+SOURCE emptyheaderstest.cpp
+MACRO EMPTY_HEADERS_TEST
+#endif //VERIFY_EMPTY_HEADERS_ACC
+
+#ifdef OBEX_EXTENSION_APIS
+SOURCE serverpacketaccessui.cpp
+#endif // OBEX_EXTENSION_APIS
+
+USERINCLUDE . ../../inc
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY euser.lib efsrv.lib esock.lib obex.lib bafl.lib c32.lib
+
+#ifdef OBEX_EXTENSION_APIS
+LIBRARY obexextensionapis.lib
+#endif // OBEX_EXTENSION_APIS
+
+// ONLY FOR IRDA:
+LIBRARY irda.lib
+
+// ONLY FOR BLUETOOTH:
+LIBRARY bluetooth.lib btmanclient.lib sdpdatabase.lib sdpagent.lib btextnotifiers.lib
+
+// Only for USB:
+LIBRARY usbman.lib
+
+// For > 1M objects
+EPOCHEAPSIZE 1024000 4096000
+
+
+// At least one of these two must be uncommented:
+MACRO TRANSPORT_BLUETOOTH // Comment this out if OBEX is not to be tested over Bluetooth
+MACRO TRANSPORT_IRDA // Comment this out if OBEX is not to be tested over IrDA
+// Uncomment this to exercise the server via MObexServerNotifyAsync rather
+// than MObexServerNotify.
+//MACRO ASYNC_INDICATION
+#ifdef OBEX_EXTENSION_APIS
+MACRO PACKET_ACCESS_EXTENSION
+MACRO ERROR_RESOLUTION_EXTENSION
+#endif //OBEX_EXTENSION_APIS
+
+VENDORID 0x70000001
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TOBEXCON.CPP Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,966 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include <e32keys.h>
+#include "TOBEXCON.H"
+#include "clienthandler.h"
+#include "serverhandlerbase.h"
+#include "serverhandler.h"
+#include "serverhandlerfile.h"
+#include "btextnotifiers.h"
+
+#ifdef EMPTY_HEADERS_TEST
+#include "emptyheaderstest.h"
+#endif //EMPTY_HEADERS_TEST
+
+#define EPOCIDENT _L8("EPOC32 ER5")
+
+
+CActiveConsole::CActiveConsole(CConsoleBase* aConsole)
+ : CActive(EPriorityNormal),
+ iConsole(aConsole),
+ iTestMode(E_Inactive),
+ iDiscoverySlots(KObexIrdaDefaultDiscoverySlotsToUse),
+ iDiscoveryAttempts(KObexIrdaDefaultDiscoveryAttempts),
+ iRecvMTU(KObexPacketDefaultSize),
+ iTransmitMTU(KObexPacketDefaultSize)
+ {
+#ifdef EMPTY_HEADERS_TEST
+ iDisplayHeaders = ETrue;
+#endif //EMPTY_HEADERS_TEST
+ }
+
+CActiveConsole* CActiveConsole::NewLC(CConsoleBase* aConsole)
+ {
+ CActiveConsole* self = new (ELeave) CActiveConsole(aConsole);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+void CActiveConsole::ConstructL ()
+ {
+ iRefHandler = CReferenceHandler::NewL();
+ iConsole->Printf(_L("\r\n"));
+ CActiveScheduler::Add(this); // Add to active scheduler
+
+ // Create private path and set default Inbox path
+ RFs fs;
+ User::LeaveIfError(fs.Connect());
+ fs.CreatePrivatePath(EDriveC);
+ fs.SetSessionToPrivate(EDriveC);
+ fs.SessionPath(iInboxRoot);
+ fs.Close();
+ }
+
+CActiveConsole::~CActiveConsole()
+ {
+ // Make sure we're cancelled
+ Cancel();
+
+ // safe to delete NULL
+ delete iObexClientHandler;
+ delete iObexServerHandler;
+ delete iObexServerHandlerFile;
+ delete iRefHandler;
+ }
+
+void CActiveConsole::DoCancel()
+ {
+ iConsole->ReadCancel();
+ }
+
+void CActiveConsole::RunL()
+ {
+ // Save the current test mode in case the next action leaves
+ TUint oldTestMode = iTestMode;
+ TRAPD(err,ProcessKeyPressL(TChar(iConsole->KeyCode())));
+ if(err != KErrNone)
+ {
+ iConsole->Printf(_L("Failed. Error: %d\r\n"),err);
+ // Put the test mode back again
+ iTestMode = oldTestMode;
+ RequestCharacter();
+ }
+ }
+
+void CActiveConsole::RequestCharacter()
+ {
+ // A request is issued to the CConsoleBase to accept a
+ // character from the keyboard.
+ if (iTestMode == E_Client)
+ {
+ iConsole->Printf(_L("Commands :- \r\n"));
+ iConsole->Printf(_L(" A - IrObex Abort\r\n"));
+ iConsole->Printf(_L(" 1 - IrObex Connect Menu\r\n"));
+ iConsole->Printf(_L(" 2 - IrObex Disconnect\r\n"));
+ iConsole->Printf(_L(" 3 - IrObex Put obj 1 : %S\r\n"), &(iObexClientHandler->iFilename1));
+ iConsole->Printf(_L(" 4 - IrObex Put Obj 2 : %S\r\n"), &(iObexClientHandler->iFilename2));
+ iConsole->Printf(_L(" z - IrObex Put Obj 3 : %S\r\n"), &(iObexClientHandler->iFilename3));
+ iConsole->Printf(_L(" y - Enter HTTP/App param Test Menu\r\n")); //E_Client_HTTP_Menu
+ iConsole->Printf(_L(" 5 - IrObex Get by name\r\n"));
+ iConsole->Printf(_L(" 6 - IrObex Get by type\r\n"));
+ iConsole->Printf(_L(" 7 - IrObex SetPath\r\n"));
+ iConsole->Printf(_L(" 8 - IrObex Put reference object\r\n"));
+ iConsole->Printf(_L(" 9 - IrObex Get reference object\r\n"));
+ iConsole->Printf(_L(" 0 - IrObex Setup OBEX\r\n"));
+ iConsole->Printf(_L(" h - Toggle display of object headers\r\n"));
+#ifdef ERROR_RESOLUTION_EXTENSION
+ iConsole->Printf(_L(" l - Display last error\r\n"));
+#endif
+#ifdef EMPTY_HEADERS_TEST
+ iConsole->Printf(_L(" t - Empty headers test menu\r\n"));
+#endif //EMPTY_HEADERS_TEST
+ iConsole->Printf(_L(" s - kill the Obex Client\r\n"));
+ }
+ if ( iTestMode == E_Client_HTTP_Menu )
+ {
+ iConsole->Printf(_L(" 1 - HTTP Multiple Packets, will all arrive\r\n"));
+ iConsole->Printf(_L(" 2 - HTTP Multiple Packets, too many arrive in two parts\r\n"));
+ iConsole->Printf(_L(" 3 - HTTP Single Packet too large, nothing will arrive\r\n"));
+ iConsole->Printf(_L(" 4 - HTTP Single Packet too large with several smaller packets which will arrive\r\n"));
+ iConsole->Printf(_L(" 5 - App parameters test\r\n"));
+ iConsole->Printf(_L(" s - Back to Client Menu\r\n"));
+ }
+ if ( iTestMode == E_Client_Connect_Menu )
+ {
+ iConsole->Printf(_L(" 0 - IrObex Disconnect\r\n"));
+ iConsole->Printf(_L(" 1 - IrObex Connect\r\n"));
+ iConsole->Printf(_L(" 2 - IrObex Connect with Authentication\r\n"));
+ iConsole->Printf(_L(" 3 - IrObex Connect with Target Header\r\n"));
+ iConsole->Printf(_L(" 4 - IrObex Connect with Authentication AND Target Header\r\n"));
+ iConsole->Printf(_L(" 5 - Get remote address\r\n"));
+ iConsole->Printf(_L(" s - Back to Client Menu\r\n"));
+ }
+ if ( iTestMode == E_Client_Setup_Menu )
+ {
+ iConsole->Printf(_L(" 1 - Change Put Object 1\r\n"));
+ iConsole->Printf(_L(" 2 - Change Put Object 2\r\n"));
+ iConsole->Printf(_L(" 3 - Change Obex Get Name : %S\r\n"), &(iObexClientHandler->iObexName));
+ iConsole->Printf(_L(" 4 - Change Obex Get Type : %S\r\n"), &(iObexClientHandler->iGetType));
+ iConsole->Printf(_L(" 5 - Enable password support (so they can challenge us)\r\n"));
+ iConsole->Printf(_L(" 6 - Set challenge password : %S\r\n"), &(iObexClientHandler->iChallengePassword));
+ iConsole->Printf(_L(" 7 - Change Authentication Challenge Header\r\n"));
+ iConsole->Printf(_L(" 8 - Set Command Time-out\r\n"));
+ iConsole->Printf(_L(" s - Back to Client Menu\r\n"));
+ iConsole->Printf(_L(" p - Set default file path : %S\r\n"), &iInboxRoot);
+ }
+ if ( iTestMode == E_Client_Authentication_Header_Menu )
+ {
+ iConsole->Printf(_L(" 1 - Suppress Options Header\r\n"));
+ iConsole->Printf(_L(" 2 - Suppress Realm Header\r\n"));
+ iConsole->Printf(_L(" 3 - Suppress Options and Realm Headers\r\n"));
+ iConsole->Printf(_L(" 4 - Reset to Default Authentication Headers\r\n"));
+ iConsole->Printf(_L(" 5 - Attempt Invalid Authentication Headers Value (i)\r\n"));
+ iConsole->Printf(_L(" s - Back to Client Menu\r\n"));
+ }
+ if (iTestMode == E_Server)
+ {
+ iConsole->Printf(_L(" 1 - Make OBEX Challenge on all incoming connections\r\n"));
+ iConsole->Printf(_L(" 2 - Disable authentication\r\n"));
+ iConsole->Printf(_L(" 3 - Enable password support (so they can challenge us)\r\n"));
+ iConsole->Printf(_L(" 4 - Set FTP local who (insist on target header\r\n"));
+ iConsole->Printf(_L(" 5 - Change challenge password : %S\r\n"), &(iObexServerHandler->iChallengePassword));
+ iConsole->Printf(_L(" 6 - Get remote address\r\n"));
+ iConsole->Printf(_L(" 7 - Set Target Checking to NoChecking\r\n"));
+ iConsole->Printf(_L(" 8 - Set Target Checking to IfPresent\r\n"));
+ iConsole->Printf(_L(" 9 - Set Target Checking to Always\r\n"));
+ iConsole->Printf(_L(" h - Toggle display of object headers\r\n"));
+ iConsole->Printf(_L(" p - Set Inbox root directory : %S\r\n"), &iInboxRoot);
+#ifdef PACKET_ACCESS_EXTENSION
+ iConsole->Printf(_L(" a - Enable displaying of request packets\r\n"));
+#endif // PACKET_ACCESS_EXTENSION
+ if(iTransport == EIrda)
+ {
+ iConsole->Printf(_L(" o - start suppressing IrDA discovery requests\r\n"));
+ iConsole->Printf(_L(" c - stop suppressing IrDA discovery requests\r\n"));
+ }
+
+ iConsole->Printf(_L("press 's' to stop the Obex Server\r\n"));
+ iConsole->Printf(_L("press 'S' to start the Obex Server\r\n"));
+ }
+ if (iTestMode == E_Server_File)
+ {
+ iConsole->Printf(_L(" Started Obex server, receiving into file-backed buffer object\r\n"));
+ iConsole->Printf(_L(" 1 - Make OBEX Challenge on all incoming connections\r\n"));
+ iConsole->Printf(_L(" 2 - Disable authentication\r\n"));
+ iConsole->Printf(_L(" 3 - Enable password support (so they can challenge us)\r\n"));
+ iConsole->Printf(_L(" 4 - Set FTP local who (insist on target header\r\n"));
+ iConsole->Printf(_L(" 5 - Change challenge password : %S\r\n"), &(iObexServerHandlerFile->iChallengePassword));
+ iConsole->Printf(_L(" 6 - Get remote address\r\n"));
+ iConsole->Printf(_L(" 7 - Toggle buffered file writes\r\n"));
+ iConsole->Printf(_L(" p - Set Inbox root directory : %S\r\n"), &iInboxRoot);
+ iConsole->Printf(_L("s - Stop the Obex Server\r\n"));
+ iConsole->Printf(_L("g - Start the Obex Server\r\n"));
+ iConsole->Printf(_L("press 'k' to kill the Obex Server\r\n"));
+ }
+
+ if(iTestMode == E_Inactive)
+ {
+ iConsole->Printf(_L("press '1' to start the Obex Client over Bluetooth\r\n"));
+ iConsole->Printf(_L("press '2' to start the Obex Server over Bluetooth\r\n"));
+ iConsole->Printf(_L("press '3' to start the Obex Client over Irda\r\n"));
+ iConsole->Printf(_L("press 'a' to set the number of discovery slots to use in Irda\r\n"));
+ iConsole->Printf(_L("press 'b' to set the number of discovery attempts to make in Irda\r\n"));
+ iConsole->Printf(_L("press '4' to start the Obex Server over Irda\r\n"));
+ iConsole->Printf(_L("press '5' to start the Obex Server over Irda (filename backed buffer object)\r\n"));
+ iConsole->Printf(_L("press 'r' to start the Obex Server over Irda (RFile backed buffer object)\r\n"));
+ iConsole->Printf(_L("press '6' to start the Obex Server over USB\r\n"));
+ iConsole->Printf(_L("press '7' to start the Obex Client over USB\r\n"));
+ iConsole->Printf(_L("press 'n' to set the IrDA Nickname\r\n"));
+ iConsole->Printf(_L("press 'm' to set the Obex Recv MTU\r\n"));
+ iConsole->Printf(_L("press 'M' to set the Obex Transmit MTU\r\n"));
+ iConsole->Printf(_L("press 'p' to toggle performance logging\r\n"));
+ }
+#ifdef EMPTY_HEADERS_TEST
+ if ( iTestMode == E_Empty_Headers_Accept_Test )
+ {
+ iConsole->Printf(_L(" 1 - Sent a packet with NOT empty following headers:\n\t[ Name, Type, Description, Target, Application Parameters ]\r\n\n"));
+ iConsole->Printf(_L(" 2 - Sent a packet with existing but empty following headers:\n\t[ Name, Type, Description, Target, Application Parameters ]\r\n\n"));
+ iConsole->Printf(_L(" s - Back to Client Menu\r\n"));
+ }
+#endif //EMPTY_HEADERS_TEST
+ if(iTestMode == E_GetIrDANickname && iIrDANicknameBuffer.Length() == 0)
+ {
+ iConsole->Printf(_L("Enter new IrDA nickname: "));
+ }
+ if(iTestMode == E_EnterRecvMTU && iRecvMTU == 0)
+ {
+ iConsole->Printf(_L("Enter new Receive MTU value (m=max, d=default): "));
+ }
+ if(iTestMode == E_EnterTransmitMTU && iTransmitMTU == 0)
+ {
+ iConsole->Printf(_L("Enter new Transmit MTU value (m=max, d=default): "));
+ }
+ //if(E_SdpQuery) // no extra options
+
+ if(iTestMode != E_GetIrDANickname &&
+ iTestMode != E_EnterRecvMTU &&
+ iTestMode != E_EnterTransmitMTU)
+ {
+ iConsole->Printf(_L("press Escape to quit\r\n\r\n"));
+ }
+ iConsole->Read(iStatus);
+ SetActive();
+ }
+
+void CActiveConsole::ProcessKeyPressL(TChar aChar)
+ {
+ if (aChar == EKeyEscape)
+ {
+ CActiveScheduler::Stop();
+ return;
+ }
+
+ if(iTestMode ==E_Inactive)
+ {
+ switch (aChar)
+ {
+ case '1':
+ iTestMode = E_SdpQuery;
+ iTransport = EBluetooth;
+ iObexClientHandler = CObexClientHandler::NewL(this, EBluetooth);
+ break;
+ case'3':
+ iTestMode = E_Client;
+ iTransport = EIrda;
+ iObexClientHandler = CObexClientHandler::NewL(this, EIrda);
+ break;
+ case 'a':
+ SetNumber(iDiscoverySlots);
+ break;
+ case 'b':
+ SetNumber(iDiscoveryAttempts);
+ break;
+ case 'n':
+ iTestMode = E_GetIrDANickname;
+ iIrDANicknameBuffer.Zero();
+ break;
+ case 'p':
+ // Toggle the internal state.
+ iPerformanceLoggingEnabled = !iPerformanceLoggingEnabled;
+ if(iPerformanceLoggingEnabled)
+ {
+ iConsole->Printf(_L("\r\nPerformance logging enabled.\r\n\r\n"));
+ }
+ else
+ {
+ iConsole->Printf(_L("\r\nPerformance logging disabled.\r\n\r\n"));
+ }
+ break;
+ case '2':
+ iTestMode = E_Server;
+ iTransport = EBluetooth;
+ iObexServerHandler = CObexServerHandler::NewL(this, EBluetooth);
+ break;
+ case '4':
+ iTestMode = E_Server;
+ iTransport = EIrda;
+ iObexServerHandler = CObexServerHandler::NewL(this, EIrda);
+ break;
+ case '5':
+ iTestMode = E_Server_File; // Added test for file-backed buffer object receive
+ iTransport = EIrda;
+ iObexServerHandlerFile = CObexServerHandlerFile::NewL(this,EIrda);
+ break;
+ case 'r':
+ iTestMode = E_Server_File; // Added test for file-backed buffer object receive
+ iTransport = EIrda;
+ iObexServerHandlerFile = CObexServerHandlerFile::NewL(this,EIrda,ETrue);
+ break;
+ case '6':
+ {
+ iTestMode = E_Server;
+
+#ifndef __WINS__
+ iTransport = EUsb;
+
+ // For USB, we unfortunately need to start it, then register our
+ // interfaces, then do a soft connect.
+ TInt err = User::LoadLogicalDevice(_L("EUSBC"));
+ if (err != KErrNone && err != KErrAlreadyExists)
+ {
+ User::Leave(err);
+ }
+
+ RUsb usb;
+ User::LeaveIfError(usb.Connect());
+ TRequestStatus status;
+ usb.TryStart(2, status);
+ User::WaitForRequest(status);
+ iConsole->Printf(_L("Starting USB returned %d\n"), status.Int());
+ User::LeaveIfError(status.Int());
+ usb.Close();
+
+ RDevUsbcClient usbDriver;
+ User::LeaveIfError(usbDriver.Open(0));
+ User::LeaveIfError(usbDriver.DeviceDisconnectFromHost());
+
+ iObexServerHandler = CObexServerHandler::NewL(this, EUsb);
+
+ User::LeaveIfError(usbDriver.DeviceConnectToHost());
+ usbDriver.Close();
+
+#else
+
+ iTransport = EWin32Usb;
+ iObexServerHandler = CObexServerHandler::NewL(this, EWin32Usb);
+#endif
+
+ }
+ break;
+ case '7':
+ {
+ iTestMode = E_Client;
+
+#ifdef __WINS__
+ iTransport = EWin32Usb;
+ iObexClientHandler = CObexClientHandler::NewL(this, EWin32Usb);
+
+#else
+
+ iTransport = EUsb;
+
+ // For USB, we unfortunately need to start it, then register our
+ // interfaces, then do a soft connect.
+ TInt loaded = User::LoadLogicalDevice(_L("EUSBC"));
+ iConsole->Printf(_L("Loading ldd returned %d\n"), loaded);
+
+ RUsb usb;
+ User::LeaveIfError(usb.Connect());
+ iConsole->Printf(_L("Connected to USB\n"));
+ TRequestStatus status;
+ usb.TryStart(2,status);
+ User::WaitForRequest(status);
+ iConsole->Printf(_L("Starting USB returned %d\n"), status.Int());
+ User::LeaveIfError(status.Int());
+ usb.Close();
+
+ RDevUsbcClient usbDriver;
+ User::LeaveIfError(usbDriver.Open(0));
+ User::LeaveIfError(usbDriver.DeviceDisconnectFromHost());
+
+ iObexClientHandler = CObexClientHandler::NewL(this, EUsb);
+
+ User::LeaveIfError(usbDriver.DeviceConnectToHost());
+ usbDriver.Close();
+#endif
+
+ }
+ break;
+ case 'm':
+ // Reset MTU value.
+ iRecvMTU = 0;
+ iTestMode = E_EnterRecvMTU;
+ break;
+
+ case 'M':
+ // Reset MTU value.
+ iTransmitMTU = 0;
+ iTestMode = E_EnterTransmitMTU;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ else if(iTestMode == E_Server)
+ {
+ switch (aChar)
+ {
+ case 's':
+ iObexServerHandler->Stop();
+ break;
+ case 'S':
+ iObexServerHandler->Start();
+ break;
+ case 'g': case 'G':
+ iObexServerHandler->Start();
+ break;
+ case 'h': case 'H':
+ iDisplayHeaders = !iDisplayHeaders;
+ break;
+ case 'k': case 'K':
+ delete iObexServerHandler;
+ iObexServerHandler = NULL;
+ iTestMode = E_Inactive;
+ break;
+ case 'o':
+ if(iTransport == EIrda)
+ {
+ iSupp.Open();
+ }
+ break;
+ case 'c':
+ if(iTransport == EIrda)
+ {
+ iSupp.Close();
+ }
+ break;
+ case '1':
+ iObexServerHandler->EnableAuthentication();
+ break;
+ case '2':
+ iObexServerHandler->DisableAuthentication();
+ break;
+ case '3':
+ iObexServerHandler->EnablePassword();
+ break;
+ case '4':
+ iObexServerHandler->SetLocalWho();
+ break;
+ case '5':
+ iObexServerHandler->ChangeChallengePassword();
+ break;
+ case '6':
+ iObexServerHandler->RemoteAddress();
+ break;
+ case '7':
+ iObexServerHandler->SetTargetChecking(CObexServer::ENoChecking);
+ break;
+ case '8':
+ iObexServerHandler->SetTargetChecking(CObexServer::EIfPresent);
+ break;
+ case '9':
+ iObexServerHandler->SetTargetChecking(CObexServer::EAlways);
+ break;
+ case 'p':
+ SetInboxRoot();
+ break;
+#ifdef PACKET_ACCESS_EXTENSION
+ case 'a':
+ iObexServerHandler->PacketAccessUiL(ETrue);
+ break;
+#endif // PACKET_ACCESS_EXTENSION
+ default:
+ iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+ break;
+ }
+ }
+
+ else if(iTestMode == E_Server_File)
+ {
+ switch (aChar)
+ {
+ case 's': case 'S':
+ iObexServerHandlerFile->Stop();
+ delete iObexServerHandlerFile;
+ iObexServerHandlerFile = NULL;
+ iTestMode = E_Inactive;
+ break;
+ case '1':
+ iObexServerHandlerFile->EnableAuthentication();
+ break;
+ case '2':
+ iObexServerHandlerFile->DisableAuthentication();
+ break;
+ case '3':
+ iObexServerHandlerFile->EnablePassword();
+ break;
+ case '4':
+ iObexServerHandlerFile->SetLocalWho();
+ break;
+ case '5':
+ iObexServerHandlerFile->ChangeChallengePassword();
+ break;
+ case '6':
+ iObexServerHandlerFile->RemoteAddress();
+ break;
+ case '7':
+ iObexServerHandlerFile->ToggleWriteBuffering();
+ break;
+ case 'p':
+ SetInboxRoot();
+ break;
+
+ default:
+ iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+ break;
+ }
+ }
+
+ else if (iTestMode == E_Client_Connect_Menu )
+ {
+ switch (aChar)
+ {
+ case '0':
+ iObexClientHandler->Disconnect();
+ break;
+ case '1':
+ iObexClientHandler->Connect();
+ break;
+ case '2':
+ iObexClientHandler->ConnectWithAuthenticationL();
+ break;
+ case '3':
+ iObexClientHandler->ConnectWithTarget();
+ break;
+ case '4':
+ iObexClientHandler->ConnectWithAuthenticationAndTargetL();
+ break;
+ case '5':
+ iObexClientHandler->RemoteAddress();
+ break;
+ default:
+ iTestMode = E_Client;
+ break;
+ }
+ }
+ else if ( iTestMode == E_Client_HTTP_Menu )
+ {
+ switch (aChar) //tam
+ {
+ case '1': //HTTP Multiple Packets;
+ iObexClientHandler->HTTPTest1L();
+ break;
+ case '2': //HTTP Multiple Packets, too many, will arrive in two parts
+ iObexClientHandler->HTTPTest2L();
+ break;
+ case '3': //HTTP Single Packet too large, nothing will arrive
+ iObexClientHandler->HTTPTest3L();
+ break;
+ case '4': //HTTP Single Packet too large
+ //with several smaller packets which will arrive
+ iObexClientHandler->HTTPTest4L();
+ break;
+ case '5': //App parameters test
+ iObexClientHandler->AppParamsTestL();
+ default:
+ iTestMode = E_Client;
+ break;
+ }
+
+ }
+ else if (iTestMode == E_Client_Setup_Menu )
+ {
+ switch (aChar)
+ {
+ case '1':
+ iObexClientHandler->SetName(iObexClientHandler->iFilename1);
+ break;
+ case '2':
+ iObexClientHandler->SetName(iObexClientHandler->iFilename2);
+ break;
+ case '3':
+ iObexClientHandler->SetObexName();
+ break;
+ case '4':
+ iObexClientHandler->SetType();
+ break;
+ case '5':
+ iObexClientHandler->EnablePassword();
+ break;
+ case '6':
+ iObexClientHandler->ChangeChallengePassword();
+ break;
+ case '7':
+ iTestMode = E_Client_Authentication_Header_Menu;
+ break;
+ case '8':
+ iObexClientHandler->SetCommandTimeout();
+ break;
+ case 'p':
+ SetInboxRoot();
+ break;
+ default:
+ iTestMode = E_Client;
+ break;
+ }
+ }
+ else if(iTestMode == E_Client)
+ {
+ switch (aChar)
+ {
+ case 'a': case 'A':
+ iObexClientHandler->Abort();
+ break;
+ case '1':
+ iTestMode = E_Client_Connect_Menu;
+ break;
+ case '2':
+ iObexClientHandler->Disconnect();
+ break;
+ case '3':
+ iObexClientHandler->Put(iObexClientHandler->iFilename1);
+ break;
+ case '4':
+ iObexClientHandler->Put(iObexClientHandler->iFilename2);
+ break;
+ case 'y':case 'Y':
+ iTestMode = E_Client_HTTP_Menu;
+ break;
+ case 'z':case 'Z':
+ iObexClientHandler->Put(iObexClientHandler->iFilename3);
+ break;
+ case '5':
+ iObexClientHandler->GetByNameL();
+ break;
+ case '6':
+ iObexClientHandler->GetByTypeL();
+ break;
+ case '7':
+ iObexClientHandler->SetPath();
+ break;
+ case '8':
+ iObexClientHandler->SetCurrentTestNumber();
+ iObexClientHandler->PutReferenceL(10);
+ break;
+ case '9':
+ iObexClientHandler->SetCurrentTestNumber();
+ iObexClientHandler->GetReferenceL(8);
+ break;
+ case '0':
+ iTestMode = E_Client_Setup_Menu;
+ break;
+ case 'h': case 'H':
+ iDisplayHeaders = !iDisplayHeaders;
+ break;
+#ifdef ERROR_RESOLUTION_EXTENSION
+ case 'l': case 'L':
+ iObexClientHandler->LastError();
+ break;
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+ case 't':
+ iTestMode = E_Empty_Headers_Accept_Test;
+ break;
+#endif //EMPTY_HEADERS_TEST
+
+ case 's': case 'S':
+ delete iObexClientHandler;
+ iObexClientHandler = NULL;
+ iTestMode = E_Inactive;
+ break;
+ default:
+ iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+ break;
+ }
+ }
+ else if(iTestMode == E_Client_Authentication_Header_Menu)
+ {
+ switch (aChar)
+ {
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ iObexClientHandler->ChangeAuthenticationChallengeHeaders(aChar);
+ break;
+ case 's': case 'S':
+ iTestMode = E_Client_Setup_Menu;
+ break;
+ default:
+ iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+ break;
+ }
+ }
+ else if(iTestMode == E_GetIrDANickname)
+ {
+ if(aChar.IsControl() ||
+ iIrDANicknameBuffer.Length() == iIrDANicknameBuffer.MaxSize())
+ {
+ // Return to main menu.
+ iTestMode = E_Inactive;
+ iConsole->Printf(_L("\nNickname set to: %S\n\n"), &iIrDANicknameBuffer);
+ }
+ else
+ {
+ iConsole->Printf(_L("%c"), aChar.operator TUint());
+ iIrDANicknameBuffer.Append(aChar);
+ }
+ }
+ else if(iTestMode == E_EnterRecvMTU)
+ {
+ if(aChar.IsDigit())
+ {
+ iRecvMTU *= 10;
+ iRecvMTU += aChar.GetNumericValue();
+ iConsole->Printf(_L("%c"), aChar.operator TUint());
+ if(iRecvMTU >= KObexPacketMaxSize)
+ {
+ // Return to main menu.
+ iTestMode = E_Inactive;
+ }
+ }
+ else
+ {
+ if(aChar == 'm')
+ {
+ // Set max MTU
+ iRecvMTU = KObexPacketMaxSize;
+ // Return to main menu.
+ iTestMode = E_Inactive;
+ }
+ else if(aChar == 'd')
+ {
+ // Set defualt MTU
+ iRecvMTU = 4000;
+ // Return to main menu.
+ iTestMode = E_Inactive;
+ }
+ else if(aChar.IsControl())
+ {
+ // Return to main menu.
+ iTestMode = E_Inactive;
+ }
+
+ iConsole->Printf(_L("\nReceive MTU set to: %d\n\n"), iRecvMTU);
+ }
+ }
+ else if(iTestMode == E_EnterTransmitMTU)
+ {
+ if(aChar.IsDigit())
+ {
+ iTransmitMTU *= 10;
+ iTransmitMTU += aChar.GetNumericValue();
+ iConsole->Printf(_L("%c"), aChar.operator TUint());
+ if(iTransmitMTU >= KObexPacketMaxSize)
+ {
+ // Return to main menu.
+ iTestMode = E_Inactive;
+ }
+ }
+ else
+ {
+ if(aChar == 'm')
+ {
+ // Set max MTU
+ iTransmitMTU = KObexPacketMaxSize;
+ // Return to main menu.
+ iTestMode = E_Inactive;
+ }
+ else if(aChar == 'd')
+ {
+ // Set defualt MTU
+ iTransmitMTU = 4000;
+ // Return to main menu.
+ iTestMode = E_Inactive;
+ }
+ else if(aChar.IsControl())
+ {
+ // Return to main menu.
+ iTestMode = E_Inactive;
+ }
+
+ iConsole->Printf(_L("\nTransmit MTU set to: %d\n\n"), iTransmitMTU);
+ }
+ }
+#ifdef EMPTY_HEADERS_TEST
+ else if ( iTestMode == E_Empty_Headers_Accept_Test )
+ {
+ switch (aChar)
+ {
+ case '1' :
+ iObexClientHandler->EmptyHeaderTestL(_L("Name header"), _L8("Type header"), _L("Description header"), _L8("Target header"), _L8("Application param header"));
+ break;
+
+ case '2':
+ iObexClientHandler->EmptyHeaderTestL(_L(""), _L8(""), _L(""), _L8(""), _L8(""));
+ break;
+
+ case 's':
+ iTestMode = E_Client;
+ break;
+
+ default :
+ iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
+ }
+
+ }
+#endif //EMPTY_HEADERS_TEST
+
+ else
+ {
+ CActiveScheduler::Stop();
+ return;
+ }
+ RequestCharacter ();
+ return;
+ }
+
+CConsoleBase* CActiveConsole::Console()
+ {
+ return iConsole;
+ }
+
+void CActiveConsole::SetPassword(TDes& aPassword)
+ {
+ iConsole->Printf(_L("\nEnter a password: %S"),&aPassword);
+
+ GetString(aPassword);
+
+ iConsole->Printf(_L("\n"));
+ iConsole->Printf( _L("\n Password size = %d\n"),aPassword.Length());
+ }
+
+
+void CActiveConsole::SetInboxRoot()
+ {
+ iConsole->Printf(_L("\nEnter a path: %S"), &iInboxRoot);
+
+ GetString(iInboxRoot);
+
+ iConsole->Printf(_L("\n"));
+ }
+
+
+TBool CActiveConsole::DisplayHeaders()
+ {
+ return iDisplayHeaders;
+ }
+
+TBool CActiveConsole::SetNumber(TUint& aNumber)
+ {
+ TKeyCode code;
+ TBuf<1> ch;
+ TBuf<64> input;
+ TUint oldNumber = aNumber;
+
+ input.Num(aNumber);
+ iConsole->Printf(_L("\nEnter a number: %S"), &input);
+
+ FOREVER
+ {
+ code = iConsole->Getch();
+ ch.SetLength(0);
+ ch.Append(code);
+
+ iConsole->Printf(_L("%S"), &ch);
+
+ // If <CR> finish editing string.
+ if (code == EKeyEnter)
+ {
+ break;
+ }
+
+ // If <BS> remove last character.
+ if ((code == EKeyBackspace) && (input.Length() != 0))
+ {
+ input.SetLength((input.Length() - 1));
+ }
+ else
+ {
+ input.Append(code);
+ }
+ }
+ iConsole->Printf(_L("\n"));
+
+ TLex lex(input);
+ if (lex.Val(aNumber) != KErrNone)
+ {
+ iConsole->Printf(_L("\r\nError: You did not enter a number.\r\n"));
+ aNumber = oldNumber;
+ return EFalse;
+ }
+
+ return ETrue;
+ }
+
+void CActiveConsole::GetString(TDes& aString)
+ {
+ TKeyCode code;
+ TBuf<1> character;
+
+ FOREVER
+ {
+ code = iConsole->Getch();
+ character.SetLength(0);
+ character.Append(code);
+
+ iConsole->Printf(_L("%S"),&character);
+
+ // If <CR> finish editing string
+ if (code == EKeyEnter)
+ break;
+
+ // if <BS> remove last character
+ if ((code == EKeyBackspace) && (aString.Length() != 0))
+ {
+ aString.SetLength((aString.Length()-1));
+ }
+ else if (aString.Length() < aString.MaxLength())
+ {
+ aString.Append(code);
+ }
+ }
+ }
+
+void CActiveConsole::ClientErrored()
+ {
+ iTestMode = E_Inactive;
+ Cancel();
+ RequestCharacter();
+ delete iObexClientHandler;
+ iObexClientHandler = 0;
+ }
+
+TBool CActiveConsole::UseIrdaNickname() const
+ {
+ return (iIrDANicknameBuffer.Length() != 0);
+ }
+
+const TDesC& CActiveConsole::GetIrdaNickname() const
+ {
+ return iIrDANicknameBuffer;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TOBEXCON.H Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,141 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef _TOBEXCON_H
+#define _TOBEXCON_H
+
+#include <e32test.h>
+#include <e32cons.h>
+#include <irdaextensions.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+#include "constants.h"
+
+
+class CObexClientHandler;
+class CObexServerHandler;
+class CObexServerHandlerFile;
+class CReferenceHandler;
+
+class CActiveConsole : public CActive
+//-----------------------------------
+ {
+public:
+ // Construction
+ CActiveConsole(CConsoleBase* aConsole);
+ static CActiveConsole* NewLC(CConsoleBase* aConsole);
+ void ConstructL();
+
+ // Destruction
+ ~CActiveConsole();
+
+ // Issue request
+ void RequestCharacter();
+
+ // Cancel request.
+ // Defined as pure virtual by CActive;
+ // implementation provided by this class.
+ void DoCancel();
+
+ // Service completed request.
+ // Defined as pure virtual by CActive;
+ // implementation provided by this class,
+ void RunL();
+
+ void ProcessKeyPressL(TChar aChar);
+
+ CConsoleBase* Console();
+ void SetPassword(TDes& aPassword);
+ void SetInboxRoot();
+ TBool DisplayHeaders();
+ void GetString(TDes& aPassword);
+ TBool SetNumber(TUint& aNumber);
+ void ClientErrored();
+
+ TBool UseIrdaNickname() const;
+ const TDesC& GetIrdaNickname() const;
+
+public:
+ // Data members defined by this class
+ CConsoleBase* iConsole; // A console for reading from
+ CObexClientHandler* iObexClientHandler; // Client wrapper for CObexClient
+ CObexServerHandler* iObexServerHandler; // Client wrapper for CObexServer
+ CObexServerHandlerFile* iObexServerHandlerFile; //Client wrapper for CObexServer
+ TUint iTestMode;
+ TTransport iTransport;
+ CReferenceHandler* iRefHandler;
+ TBool iDisplayHeaders;
+ TPath iInboxRoot;
+ TUint iDiscoverySlots;
+ TUint iDiscoveryAttempts;
+ TUint16 iRecvMTU;
+ TUint16 iTransmitMTU;
+ RIrdaDiscoveryResponseSuppressor iSupp;
+ TBuf<20> iIrDANicknameBuffer;
+ TBool iPerformanceLoggingEnabled;
+ };
+
+
+
+
+class CReferenceHandler : public CBase
+ {
+public:
+
+ enum TObexBufObjectComparison
+ {
+ EAllSame = 0,
+ EDifferentName = 1,
+ EDifferentType = 2,
+ EDifferentLength = 4,
+ EDifferentTime = 8,
+ EDifferentDescription = 16,
+ EDifferentTarget = 32,
+ EDifferentBuf = 64,
+ EDifferentHttp = 128,
+ EDifferentAppParam = 256,
+ EDifferentUserDefined = 512,
+ EDifferentCount = 1024,
+ EDifferentCreatorID = 2048,
+ EDifferentWanUUID = 4096,
+ EDifferentObjectClass = 8192};
+
+ static CReferenceHandler* NewL();
+ CReferenceHandler();
+ ~CReferenceHandler();
+
+ void CreateReferenceL(CObexBufObject& aObject, CBufFlat& aObjectBuf, TInt aReferenceId, TTransport aTransport);
+
+ TInt CompareObjectToReferenceL(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+
+private:
+ void CreateReferenceObject1L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+ void CreateReferenceObject2L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+ void CreateReferenceObject3L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+ void CreateReferenceObject4L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+ void CreateReferenceObject5L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+ void CreateReferenceObject6L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+ void CreateReferenceObject7L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+ void CreateReferenceObject8L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+ void CreateReferenceObject9L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+ void CreateReferenceObject10L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport);
+
+ };
+
+#endif // _TOBEXCON_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/TREFHANDLER.CPP Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,1236 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "TOBEXCON.H"
+#include "obexconstantsinternal.h"
+
+//reference object constants
+_LIT8(KAlphabet, "abcdefghijklmnopqrstuvwxyz");
+
+_LIT8(KRefType, "text/plain");
+_LIT8(KRefRichTextType, "text/richtext");
+_LIT8(KRefImageJpegType, "image/jpeg");
+
+_LIT8(KRefIrMCTarget, "IRMC-SYNC");
+_LIT8(KRefSyncMLTarget, "SYNCML-SYNC");
+
+
+CReferenceHandler* CReferenceHandler::NewL()
+{
+ CReferenceHandler* self = new (ELeave) CReferenceHandler();
+ return self;
+}
+
+CReferenceHandler::CReferenceHandler()
+{
+}
+
+CReferenceHandler::~CReferenceHandler()
+{
+}
+
+
+
+void CReferenceHandler::CreateReferenceL(CObexBufObject& aObject, CBufFlat& aObjectBuf, TInt aReferenceId, TTransport aTransport)
+{
+ switch (aReferenceId)
+ {
+ case (1) :
+ CreateReferenceObject1L(aObject,aObjectBuf,aTransport);
+ break;
+ case (2) :
+ CreateReferenceObject2L(aObject,aObjectBuf,aTransport);
+ break;
+ case (3) :
+ CreateReferenceObject3L(aObject,aObjectBuf,aTransport);
+ break;
+ case (4) :
+ CreateReferenceObject4L(aObject,aObjectBuf,aTransport);
+ break;
+ case (5) :
+ CreateReferenceObject5L(aObject,aObjectBuf,aTransport);
+ break;
+ case (6) :
+ CreateReferenceObject6L(aObject,aObjectBuf,aTransport);
+ break;
+ case (7) :
+ CreateReferenceObject7L(aObject,aObjectBuf,aTransport);
+ break;
+ case (8) :
+ CreateReferenceObject8L(aObject,aObjectBuf,aTransport);
+ break;
+ case (9) :
+ CreateReferenceObject9L(aObject,aObjectBuf,aTransport);
+ break;
+ case (10) :
+ CreateReferenceObject10L(aObject,aObjectBuf,aTransport);
+ break;
+ default :
+ CreateReferenceObject1L(aObject,aObjectBuf,aTransport);
+ break;
+ }
+}
+
+void CReferenceHandler::CreateReferenceObject1L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+ const TUint KNumOfAlphabets = 2;
+ aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+ //populate the buffer...
+ TBuf8<4> buf;
+ TUint i;
+ for (i=0; i<KNumOfAlphabets; i++)
+ {
+ buf.Zero();
+ buf.AppendNumFixedWidth(i, EDecimal, 4);
+ aObjectBuf.Write(30*i, buf);
+ aObjectBuf.Write(30*i + 4, KAlphabet);
+ }
+ //populate the object
+ aObject.SetNameL(KRef2Name); // check the deletecurrentheader method
+ aObject.SetNameL(KRef1Name);
+
+ _LIT8(KRef1HTTP, "Accept: text/*");
+ _LIT8(KRef2HTTP, "Location: http://www.w3.org");
+ _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+
+ // add Http header using old API
+ //
+/* aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+
+ // USE THE HEADER MASK TO REMOVE HTTP HEADERS FROM HEADERSET
+ // THIS DOES NOT REMOVE THE ITEMS FROM iHttp LIST - this tests
+ // the Http() function which should remove items from iHttp list
+ //
+
+ TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader;
+ headerMask->SetHeader(TObexInternalHeader::EName);
+ aObject.HeaderSet().SetMask(headerMask);
+ aObject.HeaderSet().DeleteMasked();
+ aObject.HeaderSet().SetMask(NULL);
+ delete headerMask;
+
+*/
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+
+/* if (aObject.Http())
+ {
+ NULL;
+ }
+*/
+ // add a Count header using new API
+ //
+ CObexHeader* tempheader = CObexHeader::NewL();
+ CleanupStack::PushL(tempheader);
+ tempheader->SetFourByte(TObexInternalHeader::ECount, 0xFE22FF54);
+ aObject.AddHeaderL(*tempheader);
+ CleanupStack::Pop(tempheader);
+
+ // add an Http header using new API
+ //
+ tempheader = CObexHeader::NewL();
+ CleanupStack::PushL(tempheader);
+ tempheader->SetByteSeqL(TObexInternalHeader::EHttp, KRef1HTTP);
+ aObject.AddHeaderL(*tempheader);
+ CleanupStack::Pop(tempheader);
+
+ aObject.SetTypeL(KRefType);
+ // set again to check header update functionality
+ aObject.SetTypeL(KRefType);
+ aObject.SetLengthL(aObjectBuf.Size());
+ // set again to check header update functionality
+ aObject.SetLengthL(aObjectBuf.Size());
+
+ TBuf8<40> param;
+ param.Copy(_L("\x04"));
+ param.Append(_L("\x03"));
+ param.Append(_L("App params 123"));
+ aObject.SetAppParamL(param);
+ // set again to check header update functionality
+ aObject.SetAppParamL(param);
+
+ const TTime KRef1Time = TDateTime(2003, EApril, 29, 10, 10, 10, 0);
+ aObject.SetTimeL(KRef1Time);
+ // set again to check header update functionality
+ aObject.SetTimeL(KRef1Time);
+
+ // Set up the MF description header
+ const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+ HBufC* descBuf = HBufC::NewLC(KDescLength);
+ ASSERT(descBuf);
+ TPtr ptr(descBuf->Des());
+ ptr.Zero();
+ for (i=0; i<KDescLength; i++)
+ {
+ ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+ }
+ aObject.SetDescriptionL(ptr);
+ // set again to check header update functionality
+ aObject.SetDescriptionL(ptr);
+
+ CleanupStack::PopAndDestroy(descBuf);
+
+ aObject.SetTargetL(KRefTarget);
+ // set again to check header update functionality
+ aObject.SetTargetL(KRefTarget);
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(0x30, KRef1Name);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(TObexInternalHeader::ECreatorID, 0x5F3A2343);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(0x36, KRef5Name);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(TObexInternalHeader::EWanUUID, KRefTarget);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(0x3F, KRef5Name);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByte(0xB0, 0x03);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByte(0xBF, 0x12);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByte(0xBE, 0x12);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(0xF0, 0x54545454);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+// THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic
+// 0x2F header doesnt have a FourByte HI Type.
+/* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(0x2F, 0x54);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+*/
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(0xFF, 0x00111243);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(0x73, KRefTarget);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(TObexInternalHeader::EObjectClass, KRefTarget);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ aObject.SetHeaderMask(KObexHdrName |KObexHdrType | KObexHdrLength | KObexHdrTime | KObexHdrDescription | KObexHdrTarget | KObexHdrHttp | KObexHdrCount | KObexHdrAppParam | KObexHdrUserDefined | KObexHdrObjectClass | KObexHdrWanUUID | KObexHdrCreatorID);
+
+}
+
+void CReferenceHandler::CreateReferenceObject2L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+ const TUint KNumOfObjects = 2;
+ aObjectBuf.ResizeL(KNumOfObjects * 20);
+ //populate the buffer...
+ _LIT8(KRefDesc2, "*Reference Object 2*");
+ TUint i;
+ for (i=0; i<KNumOfObjects; i++)
+ {
+ aObjectBuf.Write(20*i, KRefDesc2);
+ }
+ //populate the object
+ aObject.SetNameL(KRef2Name);
+ aObject.SetTypeL(KRefType);
+ aObject.SetLengthL(aObjectBuf.Size());
+ const TTime KRef2Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0);
+ aObject.SetTimeL(KRef2Time);
+
+ // Set up the MF description header
+ const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+ HBufC* descBuf = HBufC::NewLC(KDescLength);
+ ASSERT(descBuf);
+ TPtr ptr(descBuf->Des());
+ ptr.Zero();
+ for (i=0; i<KDescLength; i++)
+ {
+ ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+ }
+ aObject.SetDescriptionL(ptr);
+ CleanupStack::PopAndDestroy(descBuf);
+ aObject.SetTargetL(KRefIrMCTarget);
+ aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrLength | KObexHdrTime | KObexHdrDescription | KObexHdrTarget);
+}
+
+void CReferenceHandler::CreateReferenceObject3L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+ const TUint KNumOfAlphabets = 1000;
+ aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+ //populate the buffer...
+ TBuf8<4> buf;
+ TUint i;
+ for (i=0; i<KNumOfAlphabets; i++)
+ {
+ buf.Zero();
+ buf.AppendNumFixedWidth(i, EDecimal, 4);
+ aObjectBuf.Write(30*i, buf);
+ aObjectBuf.Write(30*i + 4, KAlphabet);
+ }
+ //populate the object
+ aObject.SetNameL(KRef3Name);
+ aObject.SetTypeL(KRefRichTextType);
+ aObject.SetLengthL(aObjectBuf.Size());
+ const TTime KRef3Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0);
+ aObject.SetTimeL(KRef3Time);
+
+ // Set up the MF description header
+ const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+ HBufC* descBuf = HBufC::NewLC(KDescLength);
+ ASSERT(descBuf);
+ TPtr ptr(descBuf->Des());
+ ptr.Zero();
+ for (i=0; i<KDescLength; i++)
+ {
+ ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+ }
+ aObject.SetDescriptionL(ptr);
+ CleanupStack::PopAndDestroy(descBuf);
+ aObject.SetTargetL(KRefTarget);
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(0x30, KRef1Name);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(0x36, KRef5Name);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(0x3F, KRef5Name);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByte(0xB0, 0x03);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByte(0xBF, 0x12);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(0xF0, 0x54);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+// THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic
+// 0x2F header doesnt have a FourByte HI Type.
+/* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(0x2F, 0x54);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+*/
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(0xFF, 0x43);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(0x73, KRefTarget);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrLength | KObexHdrTime | KObexHdrDescription | KObexHdrTarget | KObexHdrUserDefined);
+}
+
+void CReferenceHandler::CreateReferenceObject4L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+ const TUint KNumOfAlphabets = 200;
+ aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+ //populate the buffer...
+ TBuf8<4> buf;
+ TUint i;
+ for (i=0; i<KNumOfAlphabets; i++)
+ {
+ buf.Zero();
+ buf.AppendNumFixedWidth(i, EDecimal, 4);
+ aObjectBuf.Write(30*i, buf);
+ aObjectBuf.Write(30*i + 4, KAlphabet);
+ }
+ //populate the object
+
+ aObject.SetNameL(KRef4Name);
+ aObject.SetLengthL(aObjectBuf.Size());
+
+ // Set up the MF description header
+ const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+ HBufC* descBuf = HBufC::NewLC(KDescLength);
+ ASSERT(descBuf);
+ TPtr ptr(descBuf->Des());
+ ptr.Zero();
+ for (i=0; i<KDescLength; i++)
+ {
+ ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+ }
+ aObject.SetDescriptionL(ptr);
+ CleanupStack::PopAndDestroy(descBuf);
+ aObject.SetTargetL(KRefTarget);
+
+ TBuf8<40> param;
+ param.Copy(_L("\x04"));
+ param.Append(_L("\x03"));
+ param.Append(_L("App params 456"));
+ aObject.SetAppParamL(param);
+
+ aObject.SetHeaderMask(KObexHdrName | KObexHdrLength | KObexHdrDescription | KObexHdrTarget | KObexHdrAppParam);
+}
+
+void CReferenceHandler::CreateReferenceObject5L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+ const TUint KNumOfAlphabets = 200;
+ aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+ //populate the buffer...
+ TBuf8<4> buf;
+ TUint i;
+ for (i=0; i<KNumOfAlphabets; i++)
+ {
+ buf.Zero();
+ buf.AppendNumFixedWidth(i, EDecimal, 4);
+ aObjectBuf.Write(30*i, buf);
+ aObjectBuf.Write(30*i + 4, KAlphabet);
+ }
+ //populate the object
+ aObject.SetNameL(KRef5Name);
+ aObject.SetTypeL(KRefImageJpegType);
+ aObject.SetLengthL(aObjectBuf.Size());
+ const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!!
+ aObject.SetTimeL(KRef5Time);
+
+ _LIT8(KRef1HTTP, "Accept: text/*");
+ _LIT8(KRef2HTTP, "Location: http://www.w3.org");
+ _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+
+ // Set up the MF description header
+ const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+ HBufC* descBuf = HBufC::NewLC(KDescLength);
+ ASSERT(descBuf);
+ TPtr ptr(descBuf->Des());
+ ptr.Zero();
+ for (i=0; i<KDescLength; i++)
+ {
+ ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+ }
+ aObject.SetDescriptionL(ptr);
+ CleanupStack::PopAndDestroy(descBuf);
+ aObject.SetTargetL(KRefTarget);
+ aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrTime | KObexHdrLength | KObexHdrTime | KObexHdrDescription | KObexHdrHttp | KObexHdrTarget);
+}
+
+void CReferenceHandler::CreateReferenceObject6L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+ const TUint KNumOfAlphabets = 200;
+ aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+ //populate the buffer...
+ TBuf8<4> buf;
+ TUint i;
+ for (i=0; i<KNumOfAlphabets; i++)
+ {
+ buf.Zero();
+ buf.AppendNumFixedWidth(i, EDecimal, 4);
+ aObjectBuf.Write(30*i, buf);
+ aObjectBuf.Write(30*i + 4, KAlphabet);
+ }
+ //populate the object
+
+ aObject.SetNameL(KRef6Name);
+ aObject.SetTypeL(KRefImageJpegType);
+ aObject.SetLengthL(aObjectBuf.Size());
+ const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!!
+ aObject.SetTimeL(KRef5Time);
+
+ _LIT8(KRef1HTTP, "Accept: text/*");
+ _LIT8(KRef2HTTP, "Location: http://www.w3.org");
+ _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+/*
+ TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader;
+
+ headerMask->SetHeader(TObexInternalHeader::EName);
+ aObject.HeaderSet().SetMask(headerMask);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ if (aObject.Http())
+ {
+ NULL;
+ }
+ aObject.HeaderSet().SetMask(headerMask);
+ aObject.HeaderSet().DeleteMasked();
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ if (aObject.Http())
+ {
+ NULL;
+ }
+ aObject.HeaderSet().SetMask(headerMask);
+ aObject.HeaderSet().DeleteMasked();
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+
+
+ if (aObject.Http())
+ {
+ NULL;
+ }
+
+ aObject.HeaderSet().SetMask(headerMask);
+ aObject.HeaderSet().DeleteMasked();
+ delete headerMask;
+*/
+
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+
+/*
+ if (aObject.Http())
+ {
+ NULL;
+ }
+
+
+ aObject.HeaderSet().SetMask(NULL);
+*/
+
+ // Set up the MF description header
+ const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+ HBufC* descBuf = HBufC::NewLC(KDescLength);
+/* ASSERT(descBuf);
+ TPtr ptr(descBuf->Des());
+ ptr.Zero();
+ for (i=0; i<KDescLength; i++)
+ {
+ ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+ }
+ aObject.SetDescriptionL(ptr);
+*/ CleanupStack::PopAndDestroy(descBuf);
+
+ aObject.SetTargetL(KRefTarget);
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(0x30, KRef1Name);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(0x36, KRef5Name);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetUnicodeL(0x3F, KRef5Name);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByte(0xB0, 0x03);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByte(0xBF, 0x12);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(0xF0, 0x54);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+// THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic
+// 0x2F header doesnt have a FourByte HI Type.
+/* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(0x2F, 0x54);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+*/
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetFourByte(0xFF, 0x43);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByteSeqL(0x73, KRefTarget);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrTime | KObexHdrLength | KObexHdrHttp | KObexHdrTarget | KObexHdrUserDefined );
+}
+
+
+void CReferenceHandler::CreateReferenceObject7L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+ const TUint KNumOfAlphabets = 200;
+ aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+ //populate the buffer...
+ TBuf8<4> buf;
+ TUint i;
+ for (i=0; i<KNumOfAlphabets; i++)
+ {
+ buf.Zero();
+ buf.AppendNumFixedWidth(i, EDecimal, 4);
+ aObjectBuf.Write(30*i, buf);
+ aObjectBuf.Write(30*i + 4, KAlphabet);
+ }
+ //populate the object
+
+ aObject.SetNameL(KRef7Name);
+ aObject.SetTypeL(KRefImageJpegType);
+ aObject.SetLengthL(aObjectBuf.Size());
+ const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!!
+ aObject.SetTimeL(KRef5Time);
+
+ _LIT8(KRef1HTTP, "Accept: text/*");
+ _LIT8(KRef2HTTP, "Location: http://www.w3.org");
+ _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+
+
+ // Set up the MF description header
+ const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+ HBufC* descBuf = HBufC::NewLC(KDescLength);
+/* ASSERT(descBuf);
+ TPtr ptr(descBuf->Des());
+ ptr.Zero();
+ for (i=0; i<KDescLength; i++)
+ {
+ ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+ }
+ aObject.SetDescriptionL(ptr);
+*/
+ CleanupStack::PopAndDestroy(descBuf);
+
+ aObject.SetTargetL(KRefSyncMLTarget);
+ aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrTime | KObexHdrLength | KObexHdrHttp | KObexHdrTarget);
+}
+
+void CReferenceHandler::CreateReferenceObject8L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+ const TUint KNumOfAlphabets = 200;
+ aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+
+ //populate the buffer...
+ TBuf8<4> buf;
+ TUint i;
+ for (i=0; i<KNumOfAlphabets; i++)
+ {
+ buf.Zero();
+ buf.AppendNumFixedWidth(i, EDecimal, 4);
+ aObjectBuf.Write(30*i, buf);
+ aObjectBuf.Write(30*i + 4, KAlphabet);
+ }
+
+ //populate the object
+
+ aObject.SetNameL(KRef8Name);
+ aObject.SetTypeL(KRefType);
+ const TTime KRef10Time = TDateTime(2005, EJanuary, 17, 14, 35, 30, 0);
+ aObject.SetTimeL(KRef10Time);
+ aObject.SetTargetL(KRefIrMCTarget);
+ TBuf8<40> param;
+ param.Copy(_L("\x04"));
+ param.Append(_L("\x03"));
+ param.Append(_L("PARAM 435"));
+ aObject.SetAppParamL(param);
+
+ _LIT8(KRef1HTTP, "Accept: text/*");
+ aObject.AddHttpL(KRef1HTTP);
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ _LIT(KUserDefUnicode2, "UserDef2");
+ header->SetUnicodeL(0x34, KUserDefUnicode2);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByte(0xBC, 0x23);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ // Set up the MF description header
+ const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+ HBufC* descBuf = HBufC::NewLC(KDescLength);
+/* ASSERT(descBuf);
+ Ptr ptr(descBuf->Des());
+ ptr.Zero();
+ for (i=0; i<KDescLength; i++)
+ {
+ ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+ }
+ aObject.SetDescriptionL(ptr);
+*/
+ CleanupStack::PopAndDestroy(descBuf);
+
+ aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrTime | KObexHdrTarget | KObexHdrAppParam | KObexHdrHttp |KObexHdrUserDefined);
+}
+
+void CReferenceHandler::CreateReferenceObject9L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+ const TUint KNumOfAlphabets = 1000;
+ aObjectBuf.ResizeL(KNumOfAlphabets * 30);
+ //populate the buffer...
+ TBuf8<4> buf;
+ TUint i;
+ for (i=0; i<KNumOfAlphabets; i++)
+ {
+ buf.Zero();
+ buf.AppendNumFixedWidth(i, EDecimal, 4);
+ aObjectBuf.Write(30*i, buf);
+ aObjectBuf.Write(30*i + 4, KAlphabet);
+ }
+ //populate the object
+ aObject.SetNameL(KRef9Name);
+ aObject.SetTypeL(KRefType);
+ aObject.SetLengthL(aObjectBuf.Size());
+ const TTime KRef3Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0);
+ aObject.SetTimeL(KRef3Time);
+
+ _LIT8(KRef1HTTP, "Accept: text/*");
+ _LIT8(KRef2HTTP, "Location: http://www.bluetooth.com");
+ _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");
+
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+ aObject.AddHttpL(KRef1HTTP);
+ aObject.AddHttpL(KRef2HTTP);
+ aObject.AddHttpL(KRef3HTTP);
+
+ // Set up the MF description header
+ const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
+ HBufC* descBuf = HBufC::NewLC(KDescLength);
+/* ASSERT(descBuf);
+ Ptr ptr(descBuf->Des());
+ ptr.Zero();
+ for (i=0; i<KDescLength; i++)
+ {
+ ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
+ }
+ aObject.SetDescriptionL(ptr);
+*/
+ CleanupStack::PopAndDestroy(descBuf);
+ aObject.SetTargetL(KRefSyncMLTarget);
+ aObject.SetHeaderMask(KObexHdrName | KObexHdrHttp | KObexHdrType | KObexHdrLength | KObexHdrTime | KObexHdrDescription | KObexHdrTarget);
+}
+
+//Empty object with EoB headder
+void CReferenceHandler::CreateReferenceObject10L(CObexBufObject& aObject, CBufFlat& /*aObjectBuf*/, TTransport /*aTransport*/)
+{
+ //Reset the object (also resets the buffer)
+ aObject.Reset();
+
+ aObject.SetNameL(KRef8Name);
+ aObject.SetTypeL(KRefType);
+ const TTime KRef10Time = TDateTime(2005, EJanuary, 17, 14, 35, 30, 0);
+ aObject.SetTimeL(KRef10Time);
+ aObject.SetTargetL(KRefIrMCTarget);
+ TBuf8<40> param;
+ param.Copy(_L("\x04"));
+ param.Append(_L("\x03"));
+ param.Append(_L("PARAM 435"));
+ aObject.SetAppParamL(param);
+
+ _LIT8(KRef1HTTP, "Accept: text/*");
+ aObject.AddHttpL(KRef1HTTP);
+
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ _LIT(KUserDefUnicode2, "UserDef2");
+ header->SetUnicodeL(0x34, KUserDefUnicode2);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ header->SetByte(0xBC, 0x23);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+ header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+ TBuf8<1000> dummy;
+ header->SetByteSeqL(TObexInternalHeader::EEndOfBody, dummy);
+ aObject.AddHeaderL(*header);
+ CleanupStack::Pop(header);
+
+
+ HBufC* descBuf = HBufC::NewLC(0);
+ CleanupStack::PopAndDestroy(descBuf);
+}
+
+TInt CReferenceHandler::CompareObjectToReferenceL(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
+{
+ CBufFlat* buf = CBufFlat::NewL(3000);
+ CleanupStack::PushL(buf);
+ CObexBufObject* obj = CObexBufObject::NewL(buf);
+ CleanupStack::PushL(obj);
+
+ if (aObject.Name() == KRef1Name)
+ CreateReferenceObject1L(*obj, *buf, aTransport);
+ else if (aObject.Name() == KRef2Name)
+ CreateReferenceObject2L(*obj, *buf, aTransport);
+ else if (aObject.Name() == KRef3Name)
+ CreateReferenceObject3L(*obj, *buf, aTransport);
+ else if (aObject.Name() == KRef4Name)
+ CreateReferenceObject4L(*obj, *buf, aTransport);
+ else if (aObject.Name() == KRef5Name)
+ CreateReferenceObject5L(*obj, *buf, aTransport);
+ else if (aObject.Name() == KRef6Name)
+ CreateReferenceObject6L(*obj, *buf, aTransport);
+ else if (aObject.Name() == KRef7Name)
+ CreateReferenceObject7L(*obj, *buf, aTransport);
+ else if (aObject.Name() == KRef8Name)
+ CreateReferenceObject8L(*obj, *buf, aTransport);
+ else if (aObject.Name() == KRef9Name)
+ CreateReferenceObject9L(*obj, *buf, aTransport);
+ else //default
+ CreateReferenceObject1L(*obj, *buf, aTransport);
+
+ TInt res = 0;
+
+ if (aObject.Name() != obj->Name())
+ res |= EDifferentName;
+ if (aObject.Type() != obj->Type())
+ res |= EDifferentType;
+ if (aObject.Length() != obj->Length())
+ res |= EDifferentLength;
+ if (aObject.Time() != obj->Time())
+ res |= EDifferentTime;
+ if (aObject.Description() != obj->Description())
+ res |= EDifferentDescription;
+ if (aObject.Target() != obj->Target())
+ res |= EDifferentTarget;
+ if (aObjectBuf.Ptr(0) != buf->Ptr(0))
+ res |= EDifferentBuf;
+ if (aObject.AppParam() != obj->AppParam())
+ res |= EDifferentAppParam;
+ if (aObject.Http())
+ {
+ if ( ((aObject.Http())->Count()) == ((obj->Http())->Count()))
+ {
+ TInt arrayIndex = 0;
+ while (arrayIndex < ((aObject.Http())->Count()))
+ {
+ if ((((*aObject.Http())[arrayIndex])->Des()) != (((*obj->Http())[arrayIndex])->Des()))
+ {
+ res |= EDifferentHttp;
+ }
+ arrayIndex++;
+ }
+ }
+ else
+ {
+ res |= EDifferentHttp;
+ }
+ }
+
+
+ CObexHeader* firstHeader = CObexHeader::NewL();
+ CObexHeader* secondHeader = CObexHeader::NewL();
+
+ TInt err1 =0;
+ TInt err2 =0;
+
+/*
+ TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader;
+
+ headerMask->SetHeader(TObexInternalHeader::EName);
+
+ aObject.HeaderSet().SetMask(headerMask);
+ err1 = aObject.HeaderSet().This(firstHeader);
+ obj->HeaderSet().SetMask(headerMask);
+ err2 = obj->HeaderSet().This(secondHeader);
+
+ if (err1 == err2)
+ {
+ if (firstHeader->AsUnicodeL() != secondHeader->AsUnicodeL())
+ {
+ res |= EDifferentName;
+ }
+ }
+ else
+ {
+ res |= EDifferentName;
+ }
+
+ aObject.HeaderSet().SetMask(NULL);
+ obj->HeaderSet().SetMask(NULL);
+
+ delete headerMask;
+ delete firstHeader;
+ delete secondHeader;
+
+*/
+
+ if (aObject.Http())
+ {
+ if (obj->Http())
+ {
+ aObject.HeaderSet().First();
+ obj->HeaderSet().First();
+
+ err1 = aObject.HeaderSet().Find(TObexInternalHeader::EHttp, *firstHeader);
+ err2 = obj->HeaderSet().Find(TObexInternalHeader::EHttp, *secondHeader);
+
+ while (err1 == KErrNone && err2 == KErrNone)
+ {
+ if (firstHeader->AsByteSeq() != secondHeader->AsByteSeq())
+ {
+ res |= EDifferentHttp;
+ }
+ aObject.HeaderSet().Next();
+ obj->HeaderSet().Next();
+ err1 = aObject.HeaderSet().Find(TObexInternalHeader::EHttp, *firstHeader);
+ err2 = obj->HeaderSet().Find(TObexInternalHeader::EHttp, *secondHeader);
+ }
+ if (err1 != err2)
+ {
+ res |= EDifferentHttp;
+ }
+
+ }
+ else
+ {
+ res |= EDifferentHttp;
+ }
+ }
+ else
+ {
+ if (obj->Http())
+ {
+ res |= EDifferentHttp;
+ }
+ }
+
+
+// delete firstHeader;
+// delete secondHeader;
+
+ for (TUint8 headerNameIndex = KObexUserDefinedHdrAddrMin;
+ headerNameIndex <= KObexUserDefinedHdrAddrMax; headerNameIndex++)
+ {
+ TUint8 localHI = static_cast<TUint8>(headerNameIndex | TObexInternalHeader::EUnicode);
+
+ aObject.HeaderSet().First();
+ obj->HeaderSet().First();
+
+ err1 = aObject.HeaderSet().Find(localHI, *firstHeader);
+ err2 = obj->HeaderSet().Find(localHI, *secondHeader);
+
+ if (err1 == err2)
+ {
+ if (err1 == KErrNone)
+ {
+ if (firstHeader->AsUnicode() != secondHeader->AsUnicode())
+ {
+ res |= EDifferentUserDefined;
+ }
+ }
+ }
+ else
+ {
+ res |= EDifferentUserDefined;
+ }
+
+ localHI = static_cast<TUint8>(headerNameIndex | TObexInternalHeader::EByteSeq);
+
+ aObject.HeaderSet().First();
+ obj->HeaderSet().First();
+
+ err1 = aObject.HeaderSet().Find(localHI, *firstHeader);
+ err2 = obj->HeaderSet().Find(localHI, *secondHeader);
+
+ if (err1 == err2)
+ {
+ if (err1 == KErrNone)
+ {
+ if (firstHeader->AsByteSeq() != secondHeader->AsByteSeq())
+ {
+ res |= EDifferentUserDefined;
+ }
+ }
+ }
+ else
+ {
+ res |= EDifferentUserDefined;
+ }
+
+ localHI = static_cast<TUint8>(headerNameIndex | TObexInternalHeader::E1Byte);
+
+ aObject.HeaderSet().First();
+ obj->HeaderSet().First();
+
+ err1 = aObject.HeaderSet().Find(localHI, *firstHeader);
+ err2 = obj->HeaderSet().Find(localHI, *secondHeader);
+
+ if (err1 == err2)
+ {
+ if (err1 == KErrNone)
+ {
+ if (firstHeader->AsByte() != secondHeader->AsByte())
+ {
+ res |= EDifferentUserDefined;
+ }
+ }
+ }
+ else
+ {
+ res |= EDifferentUserDefined;
+ }
+
+ localHI = static_cast<TUint8>(headerNameIndex | TObexInternalHeader::E4Byte);
+
+ aObject.HeaderSet().First();
+ obj->HeaderSet().First();
+
+ err1 = aObject.HeaderSet().Find(localHI, *firstHeader);
+ err2 = obj->HeaderSet().Find(localHI, *secondHeader);
+
+ if (err1 == err2)
+ {
+ if (err1 == KErrNone)
+ {
+ if (firstHeader->AsFourByte() != secondHeader->AsFourByte())
+ {
+ res |= EDifferentUserDefined;
+ }
+ }
+ }
+ else
+ {
+ res |= EDifferentUserDefined;
+ }
+ }
+
+ aObject.HeaderSet().First();
+ obj->HeaderSet().First();
+ err1 = aObject.HeaderSet().Find(TObexInternalHeader::ECount, *firstHeader);
+ err2 = obj->HeaderSet().Find(TObexInternalHeader::ECount, *secondHeader);
+
+ if (err1 == err2)
+ {
+ if (err1 == KErrNone)
+ {
+ if (firstHeader->AsFourByte() != secondHeader->AsFourByte())
+ {
+ res |= EDifferentCount;
+ }
+ }
+ }
+ else
+ {
+ res |= EDifferentCount;
+ }
+
+ aObject.HeaderSet().First();
+ obj->HeaderSet().First();
+ err1 = aObject.HeaderSet().Find(TObexInternalHeader::ECreatorID, *firstHeader);
+ err2 = obj->HeaderSet().Find(TObexInternalHeader::ECreatorID, *secondHeader);
+
+ if (err1 == err2)
+ {
+ if (err1 == KErrNone)
+ {
+ if (firstHeader->AsFourByte() != secondHeader->AsFourByte())
+ {
+ res |= EDifferentCreatorID;
+ }
+ }
+ }
+ else
+ {
+ res |= EDifferentCreatorID;
+ }
+
+ aObject.HeaderSet().First();
+ obj->HeaderSet().First();
+ err1 = aObject.HeaderSet().Find(TObexInternalHeader::EWanUUID, *firstHeader);
+ err2 = obj->HeaderSet().Find(TObexInternalHeader::EWanUUID, *secondHeader);
+
+ if (err1 == err2)
+ {
+ if (err1 == KErrNone)
+ {
+ if (firstHeader->AsByteSeq() != secondHeader->AsByteSeq())
+ {
+ res |= EDifferentWanUUID;
+ }
+ }
+ }
+ else
+ {
+ res |= EDifferentWanUUID;
+ }
+
+ aObject.HeaderSet().First();
+ obj->HeaderSet().First();
+ err1 = aObject.HeaderSet().Find(TObexInternalHeader::EObjectClass, *firstHeader);
+ err2 = obj->HeaderSet().Find(TObexInternalHeader::EObjectClass, *secondHeader);
+
+ if (err1 == err2)
+ {
+ if (err1 == KErrNone)
+ {
+ if (firstHeader->AsByteSeq() != secondHeader->AsByteSeq())
+ {
+ res |= EDifferentObjectClass;
+ }
+ }
+ }
+ else
+ {
+ res |= EDifferentObjectClass;
+ }
+
+ delete firstHeader;
+ delete secondHeader;
+
+ CleanupStack::PopAndDestroy(2); //obj, buf
+
+ return res;
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/btutils.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,146 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include "btutils.h"
+#include "btextnotifiers.h"
+
+#define EPOCIDENT _L8("EPOC32 ER5")
+
+
+CRFCOMMServiceFinder* CRFCOMMServiceFinder::NewL( const TUUID& aServiceClass,
+ const TBTDevAddr& aDevAddr,
+ MRFCOMMServiceSeeker& aSeeker)
+ {
+ CRFCOMMServiceFinder* self= new (ELeave) CRFCOMMServiceFinder(aSeeker);
+ CleanupStack::PushL(self);
+ self->ConstructL(aDevAddr, aServiceClass);
+ CleanupStack::Pop();
+ return (self);
+ }
+
+
+CRFCOMMServiceFinder::~CRFCOMMServiceFinder()
+ {
+ delete iPattern;
+ delete iAgent;
+ }
+
+
+CRFCOMMServiceFinder::CRFCOMMServiceFinder(MRFCOMMServiceSeeker& aSeeker)
+: iSeeker(aSeeker)
+ {
+
+ }
+
+void CRFCOMMServiceFinder::ConstructL(const TBTDevAddr& aDevAddr, const TUUID& aServiceClass)
+ {
+ iPattern=CSdpSearchPattern::NewL();
+ iPattern->AddL(aServiceClass);
+ iAgent=CSdpAgent::NewL(*this, aDevAddr);
+ iAgent->SetRecordFilterL(*iPattern);
+ }
+
+void CRFCOMMServiceFinder::FindPortL()
+ {
+ iSearchState = ENoUuidFound;
+ iProfileVersion = -1; // version is unit16 in the spec - so this is an invalid version
+ // that will never be returned from a query
+ iPort=0xFF; // 0xFF will never be returned from a query,
+ // because RFCOMM server channels only go up to 30.
+ iAgent->NextRecordRequestL();
+ }
+
+void CRFCOMMServiceFinder::NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt /*aTotalRecordsCount*/)
+ {
+ if (aError == KErrNone)
+ {
+ //We have the record, kick off the attribute request
+ TRAP(aError,AttributeRequestL(aHandle));
+ }
+
+ if (aError != KErrNone)
+ {
+ iSeeker.SearchResult(aError, 0, 0);
+ }
+ }
+
+void CRFCOMMServiceFinder::AttributeRequestL(TSdpServRecordHandle aHandle)
+ {
+ CSdpAttrIdMatchList* attrList = CSdpAttrIdMatchList::NewL();
+ CleanupStack::PushL(attrList);
+ attrList->AddL(TAttrRange(KSdpAttrIdProtocolDescriptorList));
+ attrList->AddL(TAttrRange(KSdpAttrIdBluetoothProfileDescriptorList));
+
+ iAgent->AttributeRequestL(this, aHandle, *attrList);
+
+ CleanupStack::PopAndDestroy(attrList);
+ }
+
+MSdpElementBuilder* CRFCOMMServiceFinder::BuildUintL(const TDesC8& aUint)
+ {
+ switch (iSearchState)
+ {
+ // Extract port number
+ case EFoundRfcommUuid:
+ iPort = SdpUtil::GetUint(aUint);
+ break;
+
+ // Extract version number
+ case EFoundProfileUuid:
+ iProfileVersion = SdpUtil::GetUint(aUint);
+ break;
+ }
+
+ // Reset search state
+ iSearchState = ENoUuidFound;
+ return this;
+ }
+
+MSdpElementBuilder* CRFCOMMServiceFinder::BuildUUIDL(const TUUID& aUUID)
+ {
+ if ((aUUID == TUUID(3)) && (iPort == 0xFF))
+ {
+ // Found RFCOMM so need to get the port
+ iSearchState = EFoundRfcommUuid;
+ }
+ if ((aUUID == iPattern->At(0)) && (iProfileVersion == -1))
+ {
+ // Found Profile so need to get the version
+ iSearchState = EFoundProfileUuid;
+ }
+
+ return this;
+ }
+
+//The search can be concluded by calling back when AttributeRequestComplete gets called;
+void CRFCOMMServiceFinder::AttributeRequestComplete(TSdpServRecordHandle /*aHandle*/, TInt aError)
+ {
+ // Check if the RFCOMM port was found, send a suitable error code if not
+ if ((aError == KErrNone) && (iPort == 0xFF))
+ {
+ aError = KErrNotFound;
+ }
+
+ iSeeker.SearchResult(aError, iPort, iProfileVersion);
+ }
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/btutils.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,82 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef _BTUTILS_H
+#define _BTUTILS_H
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+
+
+
+class CRFCOMMServiceFinder;
+
+class MRFCOMMServiceSeeker
+ {
+public:
+ virtual void SearchResult(TInt aError, TUint8 aPort, TInt aProfileVersion)=0; // user implemented
+ };
+
+
+class CRFCOMMServiceFinder : public CBase,
+ public MSdpElementBuilder, public MSdpAgentNotifier
+ {
+public:
+ static CRFCOMMServiceFinder* NewL( const TUUID& aServiceClass,
+ const TBTDevAddr& aDevAddr,
+ MRFCOMMServiceSeeker& aSeeker);
+
+ ~CRFCOMMServiceFinder();
+
+ void FindPortL(); //Starts the search
+ //Inherits MSdpElementBuilder and MSdpAgentNotifier interfaces,
+ //most importantly...
+ MSdpElementBuilder* BuildUintL(const TDesC8& aUint);
+ MSdpElementBuilder* BuildUUIDL(const TUUID& aUUID);
+ MSdpElementBuilder* BuildDESL() {return this;}
+ MSdpElementBuilder* BuildDEAL() {return this;}
+ MSdpElementBuilder* StartListL() {return this;}
+ MSdpElementBuilder* EndListL() {return this;}
+ // All others are errors, so don’t override the default (leaves)
+ void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount);
+
+ void AttributeRequestResult(TSdpServRecordHandle,TSdpAttributeID,CSdpAttrValue*) {User::Panic(_L("RFCOMMSEEK"), 0);} // Not using this API form
+ void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError);
+private:
+ CRFCOMMServiceFinder(MRFCOMMServiceSeeker& aSeeker);
+ void ConstructL(const TBTDevAddr& aDevAddr, const TUUID& aServiceClass);
+ void AttributeRequestL(TSdpServRecordHandle aHandle);
+
+private:
+ enum TSdpSearchState { ENoUuidFound, EFoundRfcommUuid, EFoundProfileUuid };
+ CSdpAgent* iAgent;
+ CSdpSearchPattern* iPattern;
+ TSdpSearchState iSearchState;
+ TUint8 iPort;
+ TInt iProfileVersion;
+ MRFCOMMServiceSeeker& iSeeker;//initialised from aSeeker in the constructor
+ };
+
+
+
+#endif // _BTUTILS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/clienthandler.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,1087 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include <e32keys.h>
+#include "clienthandler.h"
+#include "TOBEXCON.H"
+#include "btextnotifiers.h"
+#include "obexconstantsinternal.h"
+
+#define EPOCIDENT _L8("EPOC32 ER5")
+
+
+
+CObexClientHandler::CObexClientHandler(CActiveConsole* aParent)
+ : CActive(EPriorityNormal), iParent(aParent), iState(EIdle)
+ {
+ }
+
+CObexClientHandler* CObexClientHandler::NewL(CActiveConsole* aParent, TTransport aTransport)
+ {
+ CObexClientHandler* self = new (ELeave) CObexClientHandler(aParent);
+
+ CleanupStack::PushL (self);
+ self->ConstructL(aTransport);
+ CActiveScheduler::Add (self);
+ CleanupStack::Pop ();
+ return (self);
+ }
+
+void CObexClientHandler::ConstructL(TTransport aTransport)
+ {
+ if (aTransport == EBluetooth)
+ {
+ // Check if an address has been provided on the cmd line.
+ TBuf<20> cmdline;
+ User::CommandLine(cmdline);
+
+ TInt ret = iDevAddr.SetReadable(cmdline);
+ if (ret < KErrNone)
+ {
+ iParent->Console()->Printf(_L("\nNo address found on command line\n"));
+
+ //Ask user which device address we should connect to...
+ RNotifier notify;
+ User::LeaveIfError(notify.Connect());
+ TBTDeviceSelectionParamsPckg pckg;
+ TBTDeviceResponseParamsPckg resPckg;
+ TRequestStatus stat;
+ notify.StartNotifierAndGetResponse(stat, KDeviceSelectionNotifierUid, pckg, resPckg);
+ User::WaitForRequest(stat);
+ notify.CancelNotifier(KDeviceSelectionNotifierUid);
+ notify.Close();
+ User::LeaveIfError(stat.Int());
+
+ iDevAddr = resPckg().BDAddr();
+ }
+
+ // Find UUID to search for
+ iParent->Console()->Printf(_L("\nPress F: FTP, Any other key: OPP"));
+ TChar code (iParent->Console()->Getch());
+ TUUID searchUUID;
+ switch(code)
+ {
+ case 'f': case 'F':
+ searchUUID = TUUID(0x1106); //FTP
+ break;
+ case 'o': case 'O':
+ default:
+ searchUUID = TUUID(0x1105); //OPP
+ }
+
+ //start the SDP Query
+ delete iSdpServiceFinder;
+ iSdpServiceFinder=0;
+ iSdpServiceFinder = CRFCOMMServiceFinder::NewL(searchUUID, iDevAddr, *this);
+ iSdpServiceFinder->FindPortL();
+ iParent->Console()->Printf(_L("\nSearching for SDP service....\n"));
+
+ // For bluetooth the client is created in SearchResult().
+ }
+ else if (aTransport == EIrda)
+ {
+ TObexIrProtocolInfo aInfo;
+ aInfo.iTransport= KObexIrTTPProtocolV2;
+ aInfo.iClassName = _L8("OBEX"); //same for unicode and narrow builds
+ aInfo.iAttributeName = _L8("IrDA:TinyTP:LsapSel");
+ aInfo.iDiscoverySlots = iParent->iDiscoverySlots;
+ aInfo.iDiscoveryAttempts = iParent->iDiscoveryAttempts;
+ //now create the obex client...
+ iClient = CObexClient::NewL (aInfo);
+ iClient->SetFinalPacketObserver(this);
+#ifdef ERROR_RESOLUTION_EXTENSION
+ iClientErrorResolver = CObexClientErrorResolver::NewL(*iClient);
+#endif // ERROR_RESOLUTION_EXTENSION
+ }
+ else if (aTransport == EUsb)
+ {
+ TObexUsbProtocolInfo aInfo;
+ aInfo.iTransport = KObexUsbProtocol;
+ aInfo.iInterfaceStringDescriptor = _L("TOBEX Client Interface");
+ //now create the obex client...
+ iClient = CObexClient::NewL (aInfo);
+ iClient->SetFinalPacketObserver(this);
+#ifdef ERROR_RESOLUTION_EXTENSION
+ iClientErrorResolver = CObexClientErrorResolver::NewL(*iClient);
+#endif // ERROR_RESOLUTION_EXTENSION
+ }
+ else if (aTransport == EWin32Usb)
+ {
+ TObexUsbProtocolInfo aInfo;
+ aInfo.iTransport = _L("Win32Usb");
+ //now create the obex client...
+ iClient = CObexClient::NewL (aInfo);
+ iClient->SetFinalPacketObserver(this);
+#ifdef ERROR_RESOLUTION_EXTENSION
+ iClientErrorResolver = CObexClientErrorResolver::NewL(*iClient);
+#endif // ERROR_RESOLUTION_EXTENSION
+ }
+ else
+ {
+ User::Invariant();
+ }
+
+#ifdef EMPTY_HEADERS_TEST
+ iObexEmptyHeaderTest = CObexEmptyHeaderTest::NewL();
+#endif //EMPTY_HEADERS_TEST
+ iFileObject = CObexFileObject::NewL();
+ iObjectBuffer = CBufFlat::NewL(8);
+ iObject = CObexBufObject::NewL(iObjectBuffer);
+ iObexName = _L("");
+ iGetType = _L("text/x-vcard");
+
+ iFilename1 = _L("Contacts.vcf");
+ iFilename2 = _L("Contacts2.vcf");
+ iFilename3 = _L("Contacts3.vcf");
+
+ iChallengePassword = _L("SecretPassword");
+ iResponsePassword = _L("SecretPassword");
+
+ iTargetHeaderObject = CObexNullObject::NewL();
+ iTargetHeaderObject->SetTargetL(KRefTarget);
+ iTargetHeaderObject->SetHeaderMask(KObexHdrTarget);
+ }
+
+
+void CObexClientHandler::SearchResult(TInt aError, TUint8 aPort, TInt aProfileVersion)
+ {
+ if (aError != KErrNone)
+ {
+ iParent->Console()->Printf(_L("\r\n Could not find SDP service in remote device : error %d \r\n"),aError);
+ iParent->ClientErrored();
+ return;
+ }
+
+ if (aProfileVersion >= 0)
+ {
+ iParent->Console()->Printf(_L("\nProfile Version 0x%04x\n"), aProfileVersion);
+ }
+ else
+ {
+ iParent->Console()->Printf(_L("\nProfile Version not supplied\n"));
+ }
+ iParent->Console()->Printf(_L("RFCOMM Port %d\n"), aPort);
+
+ TObexBluetoothProtocolInfo aInfo;
+ aInfo.iAddr.SetBTAddr(iDevAddr);
+ aInfo.iAddr.SetPort(aPort);
+ aInfo.iTransport = KObexRfcommProtocol;
+
+ TObexProtocolPolicy policy;
+ policy.SetReceiveMtu(iParent->iRecvMTU);
+ policy.SetTransmitMtu(iParent->iTransmitMTU);
+
+ //now create the obex client...
+ TRAP(aError, iClient = CObexClient::NewL(aInfo, policy));
+ if (aError)
+ {
+ iParent->Console()->Printf(_L("\r\n Could not create client! : error %d \r\n"),aError);
+ iParent->ClientErrored();
+ return;
+ }
+ iClient->SetFinalPacketObserver(this);
+#ifdef ERROR_RESOLUTION_EXTENSION
+ TRAP(aError,iClientErrorResolver = CObexClientErrorResolver::NewL(*iClient));
+ if (aError != KErrNone)
+ {
+ iParent->Console()->Printf(_L("\r\n Could not create client error resolver! : error %d \r\n"),aError);
+ iParent->ClientErrored();
+ return;
+ }
+#endif // ERROR_RESOLUTION_EXTENSION
+ iParent->Console()->Printf(_L("\nSDP search complete OK!\n"));
+ iParent->iTestMode = E_Client;
+
+ iParent->Cancel(); // cancel request for key
+ iParent->RequestCharacter(); // re-request, to re-display menu
+ }
+
+void CObexClientHandler::SetCurrentTestNumber()
+{
+ iCurrentTestNumber = 1;
+}
+
+void CObexClientHandler::ResetCurrentTestNumber()
+{
+ iCurrentTestNumber = 0;
+}
+
+void CObexClientHandler::MofpoFinalPacketStarted()
+ {
+ iParent->Console()->Printf(_L("\nFinal packet started\n"));
+ }
+
+void CObexClientHandler::MofpoFinalPacketFinished()
+ {
+ iParent->Console()->Printf(_L("\nFinal packet finished\n"));
+ }
+
+CObexClientHandler::~CObexClientHandler()
+ {
+ Cancel();
+#ifdef EMPTY_HEADERS_TEST
+ delete iObexEmptyHeaderTest;
+#endif //EMPTY_HEADERS_TEST
+ delete iObject;
+ delete iFileObject;
+ delete iClient;
+#ifdef ERROR_RESOLUTION_EXTENSION
+ delete iClientErrorResolver;
+#endif // ERROR_RESOLUTION_EXTENSION
+
+ delete iObjectBuffer;
+ delete iTargetHeaderObject;
+ delete iSdpServiceFinder;
+ }
+
+void CObexClientHandler::Abort()
+ {
+ if((iState != EPutting)&&(iState != EGetting))
+ iParent->Console()->Printf(_L("\r\n NOTE: Wrong Obex state for issuing abort\r\n"));
+ iClient->Abort();
+ }
+
+
+
+void CObexClientHandler::Connect()
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ TObexConnectInfo iLocalInfo = iClient->LocalInfo();
+ iLocalInfo.iWho = _L8("");
+ iLocalInfo.iWho = EPOCIDENT;
+ iLocalInfo.iWho.Append(_L8(" EikIrOBEXFile "));
+
+ iClient->Connect(iStatus);
+ SetActive();
+ iState = EConnecting;
+ }
+
+void CObexClientHandler::RemoteAddress()
+ {
+ TSockAddr aAddr;
+ iClient->RemoteAddr( aAddr);
+ TBTDevAddr addr = static_cast <TBTSockAddr>(aAddr).BTAddr();
+
+ TChar aChar;
+
+ iParent->Console()->Printf(_L("Remote Address = "));
+ for(TInt count = 0; count < addr.Des().Length(); count++)
+ {
+ aChar = (addr.Des()[count] & 0xf0)>>4;
+ if (aChar <= 9)
+ aChar += 0x30;
+ else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+ aChar += 'A' - 0x0a;
+ iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+ aChar = (addr.Des()[count] & 0x0f);
+ if (aChar <= 9)
+ aChar += 0x30;
+ else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+ aChar += 'A' - 0x0a;
+ iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+ }
+ iParent->Console()->Printf(_L("\r\n"));
+
+ }
+
+void CObexClientHandler::Disconnect()
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ iClient->Disconnect(iStatus);
+ SetActive();
+ iState = EDisconnecting;
+ }
+
+void CObexClientHandler::GetByNameL()
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ iObject->Reset ();
+ SetName(iObexName);
+ iObject->SetNameL (iObexName);
+ iClient->Get(*iObject, iStatus);
+ SetActive();
+ iState = EGetting;
+ }
+
+
+void CObexClientHandler::GetByTypeL()
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ iObject->Reset ();
+ TBuf8<300> buf;
+ buf.Copy(iGetType);
+ buf.Append(0);
+ iObject->SetTypeL (buf);
+ iClient->Get(*iObject, iStatus);
+ SetActive();
+ iState = EGetting;
+
+ }
+
+void CObexClientHandler::Put(TDes& aFilename)
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ TInt err;
+
+ err = SetUpObject (aFilename);
+
+ if( err != KErrNone)
+ {
+ iParent->Console()->Printf(_L("\r\n Couldnt set up object : error %d \r\n"),err);
+ return;
+ }
+
+ // Start the timer.
+ iStartTime.HomeTime();
+
+ iClient->Put(*iFileObject,iStatus);
+ SetActive();
+ iState = EPutting;
+ }
+
+void CObexClientHandler::GetReferenceL(TInt aReferenceId)
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iObjectBuffer, aReferenceId, iParent->iTransport);
+ iClient->Get(*iObject, iStatus);
+ SetActive();
+ iState = EGettingReference;
+ }
+
+
+//multiple HTTP packets sent in a single Obex packet
+void CObexClientHandler::HTTPTest1L() //tam
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ iObject->Reset ();
+ SetName(iObexName);
+ iObject->SetNameL (iObexName);
+
+ //now add in the HTTP headers
+
+ iObject->AddHttpL(_L8("Test 1 HTTP header 1\r\n"));
+ iObject->AddHttpL(_L8("Test 1 HTTP header 2\r\n"));
+ iObject->AddHttpL(_L8("Test 1 HTTP header 3\r\n"));
+ iObject->AddHttpL(_L8("Test 1 HTTP header 4\r\n"));
+ iObject->AddHttpL(_L8("Test 1 HTTP header 5\r\n"));
+ iObject->AddHttpL(_L8("Test 1 HTTP header 6\r\n"));
+ iObject->AddHttpL(_L8("Test 1 HTTP header 7\r\n"));
+ iObject->AddHttpL(_L8("Test 1 HTTP header 8\r\n"));
+ iObject->AddHttpL(_L8("Test 1 HTTP header 9\r\n"));
+ iObject->AddHttpL(_L8("Test 1 HTTP header 10\r\n"));
+
+
+ iClient->Get(*iObject, iStatus);
+ SetActive();
+ iState = EGetting;
+ }
+
+//multiple HHTP packets sent in multiple Obex packets
+void CObexClientHandler::HTTPTest2L()
+ {
+
+
+ TBuf8<520> localBuf;
+
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+
+ iObject->Reset ();
+ SetName(iObexName);
+ iObject->SetNameL (iObexName);
+
+ for ( TUint x = 0; x < 10; x++ ) //should be 10*512 HTTP packets,
+ { // which is in excess of the 4K Tranport size
+ localBuf = _L8("Test 2 HTTP Header");
+ localBuf.AppendFill(TUint(x + '1'), 500);
+
+ iObject->AddHttpL(localBuf);
+ }
+
+ iClient->Get(*iObject, iStatus);
+ SetActive();
+ iState = EGetting;
+ }
+
+//single HHTP packet too large for an Obex packet will not go
+void CObexClientHandler::HTTPTest3L()
+ {
+ HBufC8* localBuf = HBufC8::NewL(5020);
+
+
+ TPtr8 ptr = localBuf->Des();
+
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ iObject->Reset ();
+ SetName(iObexName);
+ iObject->SetNameL (iObexName);
+
+
+ ptr = _L8("Test 3 HTTP Header ");
+ ptr.AppendFill(TUint('A'), 5000);
+
+ iObject->AddHttpL(ptr);
+
+
+ iClient->Get(*iObject, iStatus);
+ SetActive();
+ iState = EGetting;
+ }
+
+//a single (too) large HTTP packet, with multiple HTTP packets
+//large one ignored, multiple smaller should all go
+void CObexClientHandler::HTTPTest4L()
+ {
+ HBufC8* localBuf = HBufC8::NewL(5020);
+
+ TPtr8 ptr = localBuf->Des();
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ iObject->Reset ();
+ SetName(iObexName);
+ iObject->SetNameL (iObexName);
+
+
+ ptr = _L8("Test 4 HTTP header 1");
+ iObject->AddHttpL(ptr);
+
+ //now for the excessively large header
+ ptr = _L8("Test 4 HTTP header 2");
+ ptr.AppendFill(TUint('B'), 5000);
+ iObject->AddHttpL(ptr);
+
+ //and a reasonable header again
+
+ ptr = _L8("Test 4 HTTP header 3");
+ iObject->AddHttpL(ptr);
+
+ iClient->Get(*iObject, iStatus);
+ SetActive();
+ iState = EGetting;
+ }
+
+
+void CObexClientHandler::AppParamsTestL()
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ iObject->Reset ();
+ SetName(iObexName);
+ iObject->SetNameL (iObexName);
+
+ TBuf8<40> param;
+ param.Copy(_L("\x04"));
+ param.Append(_L("\x03"));
+ param.Append(_L("App params 123"));
+ iObject->SetAppParamL(param);
+
+
+ iClient->Get(*iObject, iStatus);
+ SetActive();
+ iState = EGetting;
+
+
+ }
+
+void CObexClientHandler::ChangeAuthenticationChallengeHeaders(TChar aChar)
+ {
+ switch(aChar)
+ {
+ case '1':
+ // Suppress 'Options'
+ iClient->SuppressAuthenticationHeaderElements(CObex::EObexSuppressChallengeOptionsAuthElement);
+ break;
+ case '2':
+ // Suppress 'Realm'
+ iClient->SuppressAuthenticationHeaderElements(CObex::EObexSuppressRealmAuthElement);
+ break;
+ case '3':
+ // Supress both
+ iClient->SuppressAuthenticationHeaderElements(CObex::EObexSuppressAllAuthElements);
+ break;
+ case '4':
+ // Reset to default
+ iClient->SuppressAuthenticationHeaderElements(CObex::EObexNoSuppressedAuthElements);
+ break;
+ case '5':
+ // Invalid enum (magic number)
+ iClient->SuppressAuthenticationHeaderElements(static_cast<CObex::TObexSuppressedAuthElements>(0x08));
+ break;
+ default:
+ break;
+ }
+ }
+
+void CObexClientHandler::PutReferenceL(TInt aReferenceId)
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iObjectBuffer, aReferenceId, iParent->iTransport);
+ iClient->Put(*iObject,iStatus);
+ SetActive();
+ iState = EPuttingReference;
+ }
+
+TInt CObexClientHandler::SetUpObject(TDes& filename)
+ {
+// iFileObject->SetDataFileL(KNullDesC);
+ TRAPD (err, iFileObject->InitFromFileL (filename));
+
+ if (err != KErrNone)
+ {
+ RFs fs;
+ RFile f;
+ if ((fs.Connect () != KErrNone) ||
+ (f.Create (fs, filename, EFileShareExclusive | EFileWrite) != KErrNone))
+ iParent->Console()->Printf(_L("\r\nError reading '%s'.\r\nI tried to create this file for you, but failed to do that too. Sorry.\r\n\r\n"), filename.PtrZ ());
+ else
+ {
+ f.Write (_L8("Test file for sending from EPOC\r\n\r\nLooks like obex is sending OK!!\r\n"));
+ f.Close ();
+ iParent->Console()->Printf(_L("\r\nFile '%s' did not exist, so I've created one.\r\nPlease try again.\r\n\r\n"), filename.PtrZ ());
+ }
+ fs.Close ();
+ }
+
+ //iFileObject->SetNameL(iObexName);
+
+ return err;
+ }
+
+
+void CObexClientHandler::RunL ()
+ {
+ if (iStatus != KErrNone)
+ {// Handle error
+ }
+
+ switch (iState)
+ {
+ case EConnecting:
+ iParent->Console()->Printf(_L("\r\nConnect completed with error code: %d\r\n\r\n"),iStatus.Int());
+ iState = EConnected;//may not be connected actually
+ break;
+
+ case EPutting:
+ {
+ TTime finishTime;
+ finishTime.HomeTime();
+ TTimeIntervalMicroSeconds diff = finishTime.MicroSecondsFrom(iStartTime);
+
+ iParent->Console()->Printf(_L("\nObject Sent in %d"), diff.Int64());
+
+ iState = EConnected;
+ iParent->Console()->Printf(_L("\r\nPut completed with error code: %d\r\n\r\n"),iStatus.Int());
+ }
+ break;
+
+ case EGetting:
+ iState = EConnected;
+ iParent->Console()->Printf(_L("\r\nGet completed with error code: %d\r\n\r\n"),iStatus.Int());
+ DisplayObjectL();
+ SaveObject();
+ iObject->Reset ();
+ break;
+
+ case EGettingReference:
+ {
+ iState = EConnected;
+ iParent->Console()->Printf(_L("\r\nGet completed with error code: %d\r\n\r\n"),iStatus.Int());
+ if(iStatus == KErrNone)
+ {
+ DisplayObjectL();
+ TInt objComp = iParent->iRefHandler->CompareObjectToReferenceL(*iObject, *iObjectBuffer, iParent->iTransport);
+ ASSERT(objComp == 0); // Make sure what we sent (the ref obj) matches what we got
+ (void) objComp; // avoid build warning
+ // iParent->Console()->Printf(_L("\r\nReference Object Comparison Result: %d\r\n\r\n"), objComp);
+ iParent->Console()->Printf(_L("\r\nReference Object Comparison OK\r\n\r\n"));
+ }
+ else
+ {
+ iParent->Console()->Printf(_L("GET REFERENCE OBJECT FAILED\n"));
+ }
+ iObject->Reset();
+
+ if (iCurrentTestNumber < KMaxNumOfTests)
+ GetReferenceL(++iCurrentTestNumber);
+ else
+ {
+ iParent->Console()->Printf(_L("All GET tests completed\n"));
+ ResetCurrentTestNumber();
+ }
+ break;
+ }
+ case EPuttingReference:
+ iState = EConnected;
+ iParent->Console()->Printf(_L("\r\nReference Put completed with error code: %d\r\n\r\n"),iStatus.Int());
+ if(iStatus != KErrNone)
+ {
+ iParent->Console()->Printf(_L("PUT REFERENCE OBJECT FAILED\n"));
+ }
+ if (iCurrentTestNumber < KMaxNumOfTests)
+ PutReferenceL(++iCurrentTestNumber);
+ else
+ {
+ iParent->Console()->Printf(_L("All PUT tests completed\n"));
+ ResetCurrentTestNumber();
+ }
+
+ break;
+
+ case EDisconnecting:
+ iParent->Console()->Printf(_L("\r\nDisconnect completed with error code: %d\r\n\r\n"),iStatus.Int());
+ iState = EIdle;
+ break;
+ case ESettingPath:
+ iParent->Console()->Printf(_L("\r\nSetPath completed with error code: %d\r\n\r\n"),iStatus.Int());
+ iState = EConnected;
+ break;
+ default:
+ iParent->Console()->Printf(_L("\r\nTest Code is in an incorrect state: %d\r\n\r\n"),iState);
+ }
+ }
+
+void CObexClientHandler::DoCancel()
+ {
+ delete iClient;
+ iClient = NULL;
+#ifdef ERROR_RESOLUTION_EXTENSION
+ delete iClientErrorResolver;
+ iClientErrorResolver = NULL;
+#endif // ERROR_RESOLUTION_EXTENSION
+ }
+
+void CObexClientHandler::DisplayObjectL()
+ {
+ // Display Contents of CBufFlat data on current console
+ // This size is wrong if we abort, due to size being pre-allocated! DOH!
+
+ iParent->Console()->Printf(_L("Size of received object = %d\n"),iObjectBuffer->Size());
+
+ TInt err = KErrNone;
+ if (iParent->DisplayHeaders())
+ {
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+
+ iObject->HeaderSet().SetMask(NULL);
+ iObject->HeaderSet().First();
+
+ while (err == KErrNone)
+ {
+ err = iObject->HeaderSet().This(header);
+
+ switch (header->Type())
+ {
+ case (0x00): //Unicode
+ {
+ HBufC16* buf = NULL;
+ TRAPD(err, buf = HBufC16::NewL((header->AsUnicode()).Size()));
+ if (err)
+ {
+ iParent->iConsole->Printf(_L("Unicode Header (0x%x)- Error allocating memory to display\r\n"), header->HI());
+ }
+ else
+ {
+ TPtr16 type(buf->Des());
+ type.Copy(header->AsUnicode());
+
+ iParent->iConsole->Printf(_L("Unicode Header (0x%x) = : \"%S\"\r\n"), header->HI(), &type);
+ }
+ delete buf;
+ break;
+ }
+ case (0x01): // ByteSeq
+ {
+ HBufC16* buf = NULL;
+ TRAPD(err, buf = HBufC16::NewL((header->AsByteSeq()).Size()));
+ if (err)
+ {
+ iParent->iConsole->Printf(_L("ByteSeq Header (0x%x)- Error allocating memory to display\r\n"), header->HI());
+ }
+ else
+ {
+ TPtr16 type(buf->Des());
+ type.Copy(header->AsByteSeq());
+
+ iParent->iConsole->Printf(_L("ByteSeq Header (0x%x) = : \"%S\"\r\n"), header->HI(), &type);
+ }
+ delete buf;
+ break;
+ }
+ case (0x02): // Byte
+ {
+ iParent->iConsole->Printf(_L("Byte Header (0x%x) = : 0x%x\r\n"), header->HI(), header->AsByte());
+ break;
+ }
+ case (0x03): //FourByte
+ {
+ iParent->iConsole->Printf(_L("FourByte Header (0x%x) = : 0x%x\r\n"), header->HI(), header->AsFourByte());
+ break;
+ }
+ default : {break;}
+ }
+
+ err = iObject->HeaderSet().Next();
+ }
+
+ CleanupStack::Pop(header);
+ delete header;
+ }
+
+ TDateTime dt = iObject->Time().DateTime();
+ iParent->Console()->Printf(_L("\r\nTimestamp: %d/%d/%d, %d:%d:%d\r\n\r\n"),
+ dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour(), dt.Minute(), dt.Second());
+
+ TBuf8<1024> tempBuffer;
+// iObjectBuffer->Read(0, tempBuffer, iObjectBuffer->Size());
+ iObjectBuffer->Read(0, tempBuffer, tempBuffer.MaxSize() < iObjectBuffer->Size() ? tempBuffer.MaxSize() : iObjectBuffer->Size());
+ // Printf fails with Descriptor bigger than X hundred bytes so write byte at a time
+ for(TInt count = 0; count < tempBuffer.Size(); count++)
+ {
+ iParent->Console()->Printf(_L("%C"),tempBuffer[count]);
+ }
+ }
+
+void CObexClientHandler::SaveObject()
+ {
+
+ TFileName name;
+ TParse parser;
+ TBool bIsFullPath = EFalse;
+
+ _LIT(KDrive, "");
+ TBufC<10> drive(KDrive);
+
+ TPtr pDrive(drive.Des());
+
+ TInt ret = parser.Set(iObject->Name() ,0,0);
+
+ if(KErrNone == ret)
+ {
+ pDrive = parser.Drive();
+
+ if(pDrive.Length() != 0) // if == 0, relative path
+ {
+ bIsFullPath = ETrue;
+ }
+ }
+ // the case ret != KErrNone is kept for legacy purpose, TODO cope with return codes
+
+ if(!bIsFullPath)
+ {
+ name = iParent->iInboxRoot;
+ }
+
+ name.Append(iObject->Name());
+
+ TInt err = iObject->WriteToFile(name);
+ if (err == KErrAlreadyExists)
+ {
+ iParent->Console()->Printf(_L("\r\nWrite failed, File Already Exists\n"));
+ }
+ }
+
+
+void CObexClientHandler::SetPath()
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ CObex::TSetPathInfo info;
+ iParent->Console()->Printf(_L("Please enter path name ('..' = parent, '!' = Create, ' ' = empty name):\n"));
+ info.iNamePresent = ETrue;
+ SetName(info.iName);
+ info.iFlags |= 2; // Set "Don't Create" flag as default.
+
+ // Parent
+ if (info.iName.Length() >= 2 && info.iName[0] == '.' && info.iName[1] == '.')
+ {
+ info.iName.Delete(0, 2);
+ info.iFlags |= 1;
+ }
+ // Create
+ if (info.iName.Length() >= 1 && info.iName[0] == '!')
+ {
+ info.iName.Delete(0, 1);
+ info.iFlags &= ~(2); // Clear the "Don't Create" bit
+ }
+ // Empty Name
+ if (info.iName.Length() >= 1 && info.iName[0] == ' ')
+ {
+ info.iName.Delete(0, 1);
+ }
+ else if (info.iName.Length() <= 0)
+ info.iNamePresent = EFalse;
+ iClient->SetPath(info,iStatus);
+ SetActive();
+ iState = ESettingPath;
+ }
+
+void CObexClientHandler::SetObexName()
+ {
+ SetName(iObexName);
+ }
+
+void CObexClientHandler::SetType()
+ {
+ iParent->Console()->Printf(_L("\nEnter Mime type, or 1 for text/x-vcard, 2 for x-obex/folder-listing"));
+ SetName(iGetType);
+ if (iGetType == _L("1"))
+ iGetType = _L("text/x-vcard");
+ else if (iGetType == _L("2"))
+ iGetType = _L("x-obex/folder-listing");
+ }
+
+
+void CObexClientHandler::SetName(TDes& aName)
+ {
+ TBuf<64> oldName;
+ oldName = aName;
+
+ TKeyCode aCode;
+ TBuf<1> aChar;
+ iParent->Console()->Printf(_L("\nEnter a name: %S"),&aName);
+ FOREVER
+ {
+ aCode = iParent->Console()->Getch();
+ aChar.SetLength(0);
+ aChar.Append(aCode);
+
+ iParent->Console()->Printf(_L("%S"),&aChar);
+
+ // If <CR> finish editing string
+ if (aCode == EKeyEnter)
+ break;
+
+ // if <BS> remove last character
+ if ((aCode == EKeyBackspace)&&(aName.Length() != 0))
+ aName.SetLength((aName.Length()-1));
+ else
+ aName.Append(aCode);
+ }
+ iParent->Console()->Printf(_L("\n"));
+// if (aName.Length()>0)
+// iParent->Console()->Printf( _L("\n name size = %d\n"),aName.Length());
+// else
+// {
+// iParent->Console()->Printf(_L("\nERROR: name of length zero, name unchanged!\n"),aName.Length());
+// aName = oldName;
+// }
+
+ }
+
+void CObexClientHandler::ConnectWithAuthenticationL()
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+
+ iClient->ConnectL(iChallengePassword, iStatus);
+ SetActive();
+ iState = EConnecting;
+ }
+
+void CObexClientHandler::ConnectWithTarget()
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+ iClient->Connect(*iTargetHeaderObject, iStatus);
+ SetActive();
+ iState = EConnecting;
+ }
+
+void CObexClientHandler::ConnectWithAuthenticationAndTargetL()
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+ iClient->ConnectL(*iTargetHeaderObject, iChallengePassword, iStatus);
+ SetActive();
+ iState = EConnecting;
+ }
+
+
+void CObexClientHandler::EnablePassword()
+ {
+ iClient->SetCallBack(*this);
+ }
+
+void CObexClientHandler::ChangeChallengePassword()
+ {
+ iParent->SetPassword(iChallengePassword);
+ }
+
+void CObexClientHandler::SetCommandTimeout()
+ {
+ TUint timeout = 0;
+ if (iParent->SetNumber(timeout))
+ {
+ const TTimeIntervalMicroSeconds32 temp = timeout;
+ iClient->CObexClient::SetCommandTimeOut(temp);
+ iParent->Console()->Printf(_L("\r\nCommand Sucessful\r\n"));
+ }
+ }
+
+void CObexClientHandler::ChangeResponsePassword()
+ {
+ iParent->Cancel();
+ iParent->SetPassword(iResponsePassword);
+ iParent->RequestCharacter();
+ }
+
+void CObexClientHandler::GetUserPasswordL(const TDesC& aUserID)
+ {
+ iParent->Console()->Printf(_L("\r\nClient has been challenged by %S"), &aUserID);
+ ChangeResponsePassword(); //get the password from user
+// iParent->Console()->Printf(_L("\r\nUser Password requested for %S"), &aUserID);
+ iClient->UserPasswordL(iResponsePassword);
+ }
+
+#ifdef ERROR_RESOLUTION_EXTENSION
+void CObexClientHandler::LastError()
+ {
+ if (iClientErrorResolver == NULL)
+ {
+ iParent->Console()->Printf(_L("Client not started\r\n"));
+ }
+ else
+ {
+ switch (iClientErrorResolver->LastError())
+ {
+ case EObexNoExtendedError:
+ {
+ iParent->Console()->Printf(_L("No extended error\r\n"));
+ }
+ break;
+ case EObexRequestAccepted:
+ {
+ iParent->Console()->Printf(_L("Request accepted\r\n"));
+ }
+ break;
+ case EObexRequestNotAccepted:
+ {
+ iParent->Console()->Printf(_L("Request not accepted\r\n"));
+ }
+ break;
+ case EObexRequestTimeout:
+ {
+ iParent->Console()->Printf(_L("Request timeout\r\n"));
+ }
+ break;
+ case EObexRequestLocalInterruption:
+ {
+ iParent->Console()->Printf(_L("Request local interruption\r\n"));
+ }
+ break;
+ case EObexRequestLinkInterruption:
+ {
+ iParent->Console()->Printf(_L("Request link interruption\r\n"));
+ }
+ break;
+ default:
+ {
+ iParent->Console()->Printf(_L("Last Error value returned from client not recognised\r\n"));
+ }
+ }
+ }
+ }
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+void CObexClientHandler::EmptyHeaderTestL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam)
+ {
+ if(IsActive())
+ {
+ iParent->Console()->Printf(_L("\r\nError: Client handler already active\r\n"));
+ return;
+ }
+ iObexEmptyHeaderTest->SetHeadersL(aName, aType, aDesc, aTarget, aAppParam);
+ iClient->Put(*(iObexEmptyHeaderTest->ObexObject()),iStatus);
+ SetActive();
+ iState = EPutting;
+ }
+#endif //EMPTY_HEADERS_TEST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/clienthandler.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,156 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef _CLIENTHANDLER_H
+#define _CLIENTHANDLER_H
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+
+#ifdef ERROR_RESOLUTION_EXTENSION
+#include <obex/extensionapis/obexclienterrorresolver.h>
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+#include "emptyheaderstest.h"
+#endif //EMPTY_HEADERS_TEST
+
+#include "btutils.h"
+#include "constants.h"
+
+
+class CActiveConsole;
+
+class CObexClientHandler : public CActive, public MObexAuthChallengeHandler,
+ private MRFCOMMServiceSeeker,
+ public MObexFinalPacketObserver
+//-----------------------------------------------------------
+ {
+public:
+ // Construction
+ CObexClientHandler(CActiveConsole* aParent);
+ static CObexClientHandler* NewL(CActiveConsole* aParent, TTransport aTransport);
+ void ConstructL(TTransport aTransport);
+
+ // Destruction
+ ~CObexClientHandler();
+
+ void SetMode(TUint mode);
+
+ void Abort();
+ void Connect();
+ void Disconnect();
+ void GetByNameL();
+ void GetByTypeL();
+ void Put(TDes& filename);
+ void SetName(TDes& aName);
+ void SetObexName();
+ void SetPath();
+ void SetType();
+ void GetReferenceL(TInt aReferenceId);
+ void PutReferenceL(TInt aReferenceId);
+ void ChangeAuthenticationChallengeHeaders(TChar aChar);
+
+ void ConnectWithAuthenticationL();
+ void ConnectWithTarget();
+ void ConnectWithAuthenticationAndTargetL();
+ void EnablePassword();
+ void ChangeChallengePassword();
+ void SetCommandTimeout();
+ void ChangeResponsePassword();
+ void RemoteAddress();
+ void GetUserPasswordL(const TDesC& aUserID);
+ void SearchResult(TInt aError, TUint8 aPort, TInt aProfileVersion);
+ void HTTPTest1L();
+ void HTTPTest2L();
+ void HTTPTest3L();
+ void HTTPTest4L();
+ void AppParamsTestL();
+ void SetCurrentTestNumber();
+ void ResetCurrentTestNumber();
+
+ void MofpoFinalPacketStarted();
+ void MofpoFinalPacketFinished();
+#ifdef ERROR_RESOLUTION_EXTENSION
+ void LastError();
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+ void EmptyHeaderTestL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam);
+#endif //EMPTY_HEADERS_TEST
+
+private:
+ void RunL ();
+ void DoCancel ();
+ TInt SetUpObject (TDes& filename);
+ void DisplayObjectL();
+ void SaveObject();
+
+public:
+ TBuf<64> iObexName;
+ TBuf<64> iFilename1;
+ TBuf<64> iFilename2;
+ TBuf<64> iFilename3;
+ TBuf<16> iChallengePassword;
+ TBuf<16> iResponsePassword;
+ TBuf<32> iGetType;
+ TPath iInboxRoot;
+
+private:
+ enum TSendState
+ {
+ EIdle,
+ EConnecting,
+ EConnected,
+ EPutting,
+ EGetting,
+ EDisconnecting,
+ ESettingPath,
+ EGettingReference,
+ EPuttingReference
+ };
+
+ CActiveConsole* iParent;
+ CObexClient* iClient;
+#ifdef ERROR_RESOLUTION_EXTENSION
+ CObexClientErrorResolver* iClientErrorResolver;
+#endif // ERROR_RESOLUTION_EXTENSION
+
+#ifdef EMPTY_HEADERS_TEST
+ CObexEmptyHeaderTest* iObexEmptyHeaderTest;
+#endif //EMPTY_HEADERS_TEST
+
+ CObexFileObject* iFileObject;
+ CObexBufObject* iObject;
+ CBufFlat* iObjectBuffer;
+ TSendState iState;
+ CObexNullObject* iTargetHeaderObject;
+ CRFCOMMServiceFinder* iSdpServiceFinder;
+ TBTDevAddr iDevAddr;
+ TInt iCurrentTestNumber;
+
+ TTime iStartTime;
+ };
+
+
+#endif // _CLIENTHANDLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/constants.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,70 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef _TOBEXCONSTANTS_H
+#define _TOBEXCONSTANTS_H
+
+// Required to receive into a file (inc. buffered writes)
+_LIT(KFileName, "obex-temp.tmp");
+_LIT(KRFileTestFileName, "obex-RFile-temp.txt");
+
+
+_LIT(KRef1Name, "EPOCREF1OBJ");
+_LIT(KRef2Name, "EPOCREF2OBJ");
+_LIT(KRef3Name, "EPOCREF3OBJ");
+_LIT(KRef4Name, "EPOCREF4OBJ");
+_LIT(KRef5Name, "EPOCREF5OBJ");
+_LIT(KRef6Name, "EPOCREF6OBJ");
+_LIT(KRef7Name, "EPOCREF7OBJ");
+_LIT(KRef8Name, "EPOCREF8OBJ");
+_LIT(KRef9Name, "EPOCREF9OBJ");
+
+_LIT8(KRefTarget, "\xF9\xEC\x7B\xC4\x95\x3C\x11\xd2\x98\x4E\x52\x54\x00\xDC\x9E\x09"); // Folder Browsing
+
+const TInt KMaxNumOfTests = 1;
+
+static const TUid KObexTestUid = {0x12342468};
+
+enum TestMode
+ {
+ E_Inactive,
+ E_Server,
+ E_Server_File,
+ E_Client,
+ E_Client_Connect_Menu,
+ E_Client_Setup_Menu,
+ E_Client_Authentication_Header_Menu,
+ E_SdpQuery,
+ E_Auto,
+ E_Client_HTTP_Menu,
+ E_GetIrDANickname,
+ E_EnterRecvMTU,
+ E_EnterTransmitMTU,
+#ifdef EMPTY_HEADERS_TEST
+ E_Empty_Headers_Accept_Test,
+#endif //EMPTY_HEADERS_TEST
+ };
+
+enum TTransport
+ {
+ EBluetooth,
+ EIrda,
+ EUsb,
+
+ //Place holder should a Win32 emulator USB transport be created
+ EWin32Usb
+ };
+
+#endif // _TOBEXCONSTANTS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/emptyheaderstest.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,89 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifdef EMPTY_HEADERS_TEST
+
+#pragma message("Building with additional test code to allow the checking of the acceptance of OBEX requests that contain empty headers.")
+#include <e32base.h>
+#include <obexheaders.h>
+#include "emptyheaderstest.h"
+
+
+CObexEmptyHeaderTest* CObexEmptyHeaderTest::NewL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam)
+ {
+ CObexEmptyHeaderTest* ret = new (ELeave) CObexEmptyHeaderTest();
+ CleanupStack::PushL(ret);
+ ret->ConstructL( aName, aType, aDesc, aTarget, aAppParam );
+ CleanupStack::Pop();
+ return ret;
+ }
+
+
+CObexEmptyHeaderTest* CObexEmptyHeaderTest::NewL()
+ {
+ CObexEmptyHeaderTest* ret = new (ELeave) CObexEmptyHeaderTest();
+ CleanupStack::PushL(ret);
+ ret->ConstructL( _L(""), _L8(""), _L(""), _L8(""), _L8("") );
+ CleanupStack::Pop();
+ return ret;
+ }
+
+CObexEmptyHeaderTest::CObexEmptyHeaderTest()
+ {
+
+ }
+
+void CObexEmptyHeaderTest::ConstructL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam)
+ {
+ iBuffer = CBufFlat::NewL(10);
+ iBuffer->InsertL(0, _L8("CObexEmptyHeaderTest constructed, which allows the checking of the acceptance of OBEX requests that contain empty headers."));
+
+ iObexBufObject = CObexBufObject::NewL(iBuffer);
+
+ iNameHeader = CObexHeader::NewL();
+ iTypeHeader = CObexHeader::NewL();
+ iDescriptionHeader = CObexHeader::NewL();
+ iTargetHeader = CObexHeader::NewL();
+ iAppParamHeader = CObexHeader::NewL();
+
+ SetHeaders(aName, aType, aDesc, aTarget, aAppParam);
+
+ iObexBufObject->AddHeaderL( *iNameHeader );
+ iObexBufObject->AddHeaderL( *iTypeHeader );
+ iObexBufObject->AddHeaderL( *iDescriptionHeader );
+ iObexBufObject->AddHeaderL( *iTargetHeader );
+ iObexBufObject->AddHeaderL( *iAppParamHeader );
+ }
+
+void CObexEmptyHeaderTest::SetHeadersL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam)
+ {
+ iNameHeader->SetUnicodeL( 0x01, aName );
+ iTypeHeader->SetByteSeqL(0x42, aType);
+ iDescriptionHeader ->SetUnicodeL(0x05, aDesc);
+ iTargetHeader->SetByteSeqL(0x46, aTarget);
+ iAppParamHeader->SetByteSeqL(0x4C, aAppParam);
+ }
+
+CObexEmptyHeaderTest::~CObexEmptyHeaderTest()
+ {
+ delete iObexBufObject;
+ delete iBuffer;
+ }
+
+CObexBufObject* CObexEmptyHeaderTest::ObexObject() const
+ {
+ return iObexBufObject;
+ }
+#endif //EMPTY_HEADERS_TEST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/emptyheaderstest.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,50 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexobjects.h>
+
+#ifndef COBEXEMPTYHEADERTEST_HEADER
+#define COBEXEMPTYHEADERTEST_HEADER
+
+class CObexEmptyHeaderTest : public CBase
+{
+
+ public:
+ static CObexEmptyHeaderTest* NewL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam);
+ static CObexEmptyHeaderTest* NewL();
+ virtual ~CObexEmptyHeaderTest();
+
+ void SetHeadersL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam);
+ //todo const ??
+ CObexBufObject* ObexObject() const;
+
+
+ private:
+ CObexEmptyHeaderTest();
+ void ConstructL(TPtrC aName, TPtrC8 aType, TPtrC aDesc, TPtrC8 aTarget, TPtrC8 aAppParam);
+
+
+ private:
+ CObexHeader* iNameHeader;
+ CObexHeader* iTypeHeader;
+ CObexHeader* iDescriptionHeader;
+ CObexHeader* iTargetHeader;
+ CObexHeader* iAppParamHeader;
+
+ CBufFlat *iBuffer;
+ CObexBufObject *iObexBufObject;
+};
+
+#endif //COBEXEMPTYHEADERTEST_HEADER
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/readme.txt Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+TObex - Readme.txt
+
+
+TObex provides provision for the existance of a Win32 emulator USB transport plugin,
+together with a Symbian Win32 USB driver.
+These would allow TObex to use USB when running on the emulator.
+However NEITHER a Win32 emulator USB transport plugin NOR a Symbian Win32 USB driver
+are currently available.
+An attempt to load USB when running TObex on the emulator will result in a
+KErrNotFound error being posted.
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverasyncao.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,153 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "serverasyncao.h"
+#include <e32cons.h>
+#include <obexserver.h>
+
+#include <obexobjects.h>
+
+
+CServerAsyncAO* CServerAsyncAO::NewL(CObexServer& aObexServer)
+ {
+ CServerAsyncAO* self = new(ELeave) CServerAsyncAO(aObexServer);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+CServerAsyncAO::CServerAsyncAO(CObexServer& aObexServer)
+:CActive(EPriorityStandard),
+ iObexServer(aObexServer)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+void CServerAsyncAO::ConstructL()
+ {
+ iConsole = Console::NewL(_L("OBEX DLL Test Code"),TSize(55,12));
+ }
+
+CServerAsyncAO::~CServerAsyncAO()
+ {
+ delete iConsole;
+ }
+
+void CServerAsyncAO::CompletionIndication(CObex::TOperation aOpcode, TObexResponse aResponse)
+ {
+ _LIT(KPutIndication, "PutCompleteIndication\n");
+ _LIT(KGetIndication, "GetCompleteIndication\n");
+ _LIT(KSetPathIndication, "SetPathIndication\n");
+
+ iState = ECompleteIndication;
+ iDefaultResponse = aResponse;
+
+ switch(aOpcode)
+ {
+ case CObex::EOpPut:
+ iConsole->Printf(KPutIndication);
+ break;
+ case CObex::EOpGet:
+ iConsole->Printf(KGetIndication);
+ break;
+ case CObex::EOpSetPath:
+ iConsole->Printf(KSetPathIndication);
+ break;
+ default:
+ User::Invariant();
+ }
+
+ iConsole->Printf(_L("Please enter the response code: 0x%x"), aResponse);
+ iConsole->Read(iStatus);
+ SetActive();
+ }
+
+void CServerAsyncAO::RequestIndication(CObex::TOperation aOpcode, CObexBaseObject *aObject)
+ {
+ if(aOpcode == CObex::EOpPut)
+ {
+ iConsole->Printf(_L("Put"));
+ }
+ else if(aOpcode == CObex::EOpGet)
+ {
+ iConsole->Printf(_L("Get"));
+ }
+ else
+ {
+ User::Invariant();
+ }
+ iState = ERequestIndication;
+ iObject = aObject;
+ iConsole->Printf(_L("RequestIndication, press any key to continue\n"));
+ iConsole->Read(iStatus);
+ SetActive();
+ }
+
+void CServerAsyncAO::RunL()
+ {
+ TObexResponse resp = ERespSuccess;
+ TBuf<2> buf;
+
+ TKeyCode key = iConsole->KeyCode();
+
+ if(iState == ECompleteIndication)
+ {
+ buf.AppendFormat(_L("%x"), iDefaultResponse);
+ do {
+
+ if(key == EKeyBackspace&&buf.Length()!=0)
+ {
+ buf.SetLength(buf.Length()-1);
+ }
+ else if( buf.Length() < buf.MaxLength())
+ {
+ buf.Append(key);
+ }
+ else
+ continue;
+ iConsole->Printf(_L("%c"),key);
+ }
+ while((key = iConsole->Getch())!=EKeyEnter);
+ iConsole->Printf(_L("\n"));
+
+ TLex lex(buf);
+ TUint value;
+ TInt lex_err = lex.Val(value, EHex);
+
+ if(lex_err == KErrNone)
+ {
+ resp = static_cast<TObexResponse>(value);
+ }
+ else
+ {
+ iConsole->Printf(_L("Input parsing failed, use success as default response\n"));
+ }
+
+ TInt ret = iObexServer.RequestCompleteIndicationCallback(resp);
+ iConsole->Printf(_L("Server returned with error code %d\n\n"), ret);
+ }
+ else
+ {
+ TInt ret = iObexServer.RequestIndicationCallback(iObject);
+ iConsole->Printf(_L("Server returned with error code %d\n\n"), ret);
+ }
+ }
+
+void CServerAsyncAO::DoCancel()
+ {
+ iConsole->ReadCancel();
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverasyncao.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,55 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __SERVERASYNCCAO_H
+#define __SERVERASYNCCAO_H
+
+#include <obexconstants.h>
+#include <obexbase.h>
+
+class CConsoleBase;
+class CObexServer;
+
+class CServerAsyncAO : public CActive
+ {
+public:
+ static CServerAsyncAO* NewL(CObexServer& aObexServer);
+
+ ~CServerAsyncAO();
+ void CompletionIndication(CObex::TOperation aOpcode, TObexResponse aResponse);
+ void RequestIndication(CObex::TOperation aOpcode, CObexBaseObject* aObject);
+
+ void RunL();
+
+private:
+ CServerAsyncAO(CObexServer& aObexServer);
+ void ConstructL();
+ void DoCancel();
+private:
+ CConsoleBase* iConsole;
+ CObexServer& iObexServer;
+ CObexBaseObject* iObject;
+
+ enum TIndicationState
+ {
+ ERequestIndication,
+ ECompleteIndication
+ };
+ TIndicationState iState;
+ TObexResponse iDefaultResponse;
+ };
+
+#endif //SERVERASYNCCAO_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandler.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,55 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include "serverhandlerbase.h"
+#include "serverhandler.h"
+#include "TOBEXCON.H"
+#include "btextnotifiers.h"
+
+
+CObexServerHandler::CObexServerHandler(CActiveConsole* aParent)
+ : CObexServerHandlerBase(aParent)
+ {}
+
+CObexServerHandler* CObexServerHandler::NewL(CActiveConsole* aParent, TTransport aTransport)
+ {
+ CObexServerHandler* self = new (ELeave) CObexServerHandler(aParent);
+
+ CleanupStack::PushL(self);
+ self->ConstructL(aTransport);
+ CleanupStack::Pop();
+ return (self);
+ }
+
+void CObexServerHandler::ConstructL(TTransport aTransport)
+ {
+ BaseConstructL(aTransport);
+
+ iBuf = CBufFlat::NewL(5000);//5000 - what should I put??
+ iObject = CObexBufObject::NewL(NULL);
+
+ iObject->SetDataBufL(iBuf);
+ }
+
+CObexServerHandler::~CObexServerHandler()
+ {
+ delete iObject; iObject = 0;
+ delete iBuf; iBuf = 0;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandler.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,47 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef _SERVERHANDLER_H
+#define _SERVERHANDLER_H
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+
+class CActiveConsole;
+
+class CObexServerHandler : public CObexServerHandlerBase
+//-----------------------------------------------------------
+ {
+public:
+ // Construction
+ static CObexServerHandler* NewL(CActiveConsole* aParent, TTransport aTransport);
+ void ConstructL(TTransport aTransport);
+
+ ~CObexServerHandler();
+
+private:
+ CObexServerHandler(CActiveConsole* aParent);
+ };
+
+
+#endif // _SERVERHANDLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandlerbase.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,1007 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include "serverhandlerbase.h"
+#include "TOBEXCON.H"
+#include "btextnotifiers.h"
+#include "serverasyncao.h"
+#include <obexconstants.h>
+#include <obexbttransportinfo.h>
+#include <obexirtransportinfo.h>
+#include "obexconstantsinternal.h"
+
+#include "serverpacketaccessui.h"
+
+CObexServerHandlerBase::CObexServerHandlerBase(CActiveConsole* aParent)
+ : iAcceptPuts(ETrue), iParent(aParent)
+ {
+ }
+
+
+void CObexServerHandlerBase::BaseConstructL(TTransport aTransport)
+ {
+
+ iTransportLayer = aTransport;
+ switch (aTransport)
+ {
+ case (EBluetooth):
+ InitBluetoothL();
+ break;
+
+ case (EIrda):
+ {
+ if(iParent->UseIrdaNickname())
+ {
+ TObexIrV3TransportInfo aInfo;
+ aInfo.iTransportName = KObexIrTTPProtocolV3;
+ aInfo.iReceiveMtu = iParent->iRecvMTU;
+ aInfo.iTransmitMtu = iParent->iTransmitMTU;
+ aInfo.iAddr.SetPort(KAutoBindLSAP);//default obex server for now
+ _LIT8(KClassName, "OBEX");
+ _LIT8(KAttributeName, "IrDA:TinyTP:LsapSel");
+ aInfo.iClassName = KClassName;
+ aInfo.iAttributeName = KAttributeName;
+ aInfo.iDiscoverySlots = iParent->iDiscoverySlots;
+ aInfo.iDiscoveryAttempts = iParent->iDiscoveryAttempts;
+ aInfo.iLocalDeviceNickname = iParent->GetIrdaNickname();
+ aInfo.iLocalDeviceNicknameValid = ETrue;
+ iServer = CObexServer::NewL(aInfo);
+ }
+ else
+ {
+ TObexIrV2TransportInfo aInfo;
+ aInfo.iTransportName = KObexIrTTPProtocolV2;
+ aInfo.iReceiveMtu = iParent->iRecvMTU;
+ aInfo.iTransmitMtu = iParent->iTransmitMTU;
+ aInfo.iAddr.SetPort(KAutoBindLSAP);//default obex server for now
+ _LIT8(KClassName, "OBEX");
+ _LIT8(KAttributeName, "IrDA:TinyTP:LsapSel");
+ aInfo.iClassName = KClassName;
+ aInfo.iAttributeName = KAttributeName;
+ aInfo.iDiscoverySlots = iParent->iDiscoverySlots;
+ aInfo.iDiscoveryAttempts = iParent->iDiscoveryAttempts;
+ iServer = CObexServer::NewL(aInfo);
+ }
+ User::LeaveIfError(iServer->Start(this));
+
+/* // Uncomment this code to demonstrate CObexServer::TransportInfo
+ // API with TTP transport.
+ // We get back an TObexIrTransportInfo because we asked for KObexIrTTPProtocol.
+ const TObexIrTransportInfo* transportInfo = static_cast<const TObexIrTransportInfo*>(iServer->TransportInfo());
+ iParent->Console()->Printf(_L("Transport info: \r\n"));
+ iParent->Console()->Printf(_L("\ttransport name: %S\r\n"), &transportInfo->iTransportName);
+ iParent->Console()->Printf(_L("\tversion: %d\r\n"), transportInfo->iVersion);
+ iParent->Console()->Printf(_L("\treceive MTU: %d\r\n"), transportInfo->iReceiveMtu);
+ iParent->Console()->Printf(_L("\ttransmitMTU: %d\r\n"), transportInfo->iTransmitMtu);
+ iParent->Console()->Printf(_L("\tTinyTP port: 0x%02x\r\n"), transportInfo->iAddr.Port());
+ TName wide;
+ wide.Copy(transportInfo->iClassName);
+ iParent->Console()->Printf(_L("\tclass name: %S\r\n"), &wide);
+ wide.Copy(transportInfo->iAttributeName);
+ iParent->Console()->Printf(_L("\tattribute name: %S\r\n"), &wide);
+*/
+ break;
+ }
+
+ case (EUsb):
+ {
+ TObexUsbProtocolInfo info;
+ info.iTransport = KObexUsbProtocol;
+ info.iInterfaceStringDescriptor = _L("TOBEX Server Interface");
+
+ iServer = CObexServer::NewL (info);
+ User::LeaveIfError(iServer->Start (this));
+
+/* // Uncomment this code to demonstrate CObexServer::TransportInfo
+ // API with USB transport.
+ // We get back an TObexUsbTransportInfo because we asked for KObexUsbProtocol.
+ const TObexUsbTransportInfo* transportInfo = static_cast<const TObexUsbTransportInfo*>(iServer->TransportInfo());
+ iParent->Console()->Printf(_L("Transport info: \r\n"));
+ iParent->Console()->Printf(_L("\ttransport name: %S\r\n"), &transportInfo->iTransportName);
+ iParent->Console()->Printf(_L("\tversion: %d\r\n"), transportInfo->iVersion);
+ iParent->Console()->Printf(_L("\treceive MTU: %d\r\n"), transportInfo->iReceiveMtu);
+ iParent->Console()->Printf(_L("\ttransmitMTU: %d\r\n"), transportInfo->iTransmitMtu);
+ iParent->Console()->Printf(_L("\tinterface string desc: %S\r\n"), &transportInfo->iInterfaceStringDescriptor);
+*/
+ break;
+ }
+
+ case (EWin32Usb):
+ {
+ TObexUsbProtocolInfo aInfo;
+ aInfo.iTransport = _L("Win32Usb");
+ aInfo.iInterfaceStringDescriptor = _L("TOBEX Server Interface");
+
+ iServer = CObexServer::NewL (aInfo);
+ User::LeaveIfError(iServer->Start (this));
+
+/* // Uncomment this code to demonstrate CObexServer::TransportInfo
+ // API with Win32USB transport.
+ // We get back an TObexUsbTransportInfo because we asked for KObexUsbProtocol.
+ const TObexUsbTransportInfo* transportInfo = static_cast<const TObexUsbTransportInfo*>(iServer->TransportInfo());
+ iParent->Console()->Printf(_L("Transport info: \r\n"));
+ iParent->Console()->Printf(_L("\ttransport name: %S\r\n"), &transportInfo->iTransportName);
+ iParent->Console()->Printf(_L("\tversion: %d\r\n"), transportInfo->iVersion);
+ iParent->Console()->Printf(_L("\treceive MTU: %d\r\n"), transportInfo->iReceiveMtu);
+ iParent->Console()->Printf(_L("\ttransmitMTU: %d\r\n"), transportInfo->iTransmitMtu);
+ iParent->Console()->Printf(_L("\tinterface string desc: %S\r\n"), &transportInfo->iInterfaceStringDescriptor);
+*/
+ break;
+ }
+ }
+
+#ifdef ASYNC_INDICATION
+ iServerAsyncAO = CServerAsyncAO::NewL(*iServer);
+#endif
+ }
+
+void CObexServerHandlerBase::InitBluetoothL()
+ {
+ TBTServiceSecurity serv;
+ serv.SetUid(KObexTestUid);
+
+ // UPF - change security here for Bluetooth security testing
+ serv.SetAuthentication(EFalse);
+ serv.SetAuthorisation(EFalse);
+ serv.SetEncryption(EFalse);
+
+ // now set up Obex...
+ TObexBluetoothProtocolInfo info;
+ info.iTransport = KObexRfcommProtocol;
+ info.iAddr.SetPort(KRfcommPassiveAutoBind);
+ info.iAddr.SetSecurity(serv);
+
+ TObexProtocolPolicy policy;
+ policy.SetReceiveMtu(iParent->iRecvMTU);
+ policy.SetTransmitMtu(iParent->iTransmitMTU);
+
+ iServer = CObexServer::NewL(info, policy);
+ iServer->SetReadActivityObserver(this);
+
+ User::LeaveIfError(iServer->Start (this));
+ // We get back an TObexBtTransportInfo because we asked for KObexRfcommProtocol.
+ const TObexBtTransportInfo* transportInfo = static_cast<const TObexBtTransportInfo*>(iServer->TransportInfo());
+ iParent->Console()->Printf(_L("Transport info: \r\n"));
+ iParent->Console()->Printf(_L("\ttransport name: %S\r\n"), &transportInfo->iTransportName);
+ iParent->Console()->Printf(_L("\tversion: %d\r\n"), transportInfo->iVersion);
+ iParent->Console()->Printf(_L("\treceive MTU: %d\r\n"), transportInfo->iReceiveMtu);
+ iParent->Console()->Printf(_L("\ttransmitMTU: %d\r\n"), transportInfo->iTransmitMtu);
+ iParent->Console()->Printf(_L("\tRFCOMM port: 0x%02x\r\n"), transportInfo->iAddr.Port());
+
+ // SDP registration
+ User::LeaveIfError(iSdp.Connect());
+ User::LeaveIfError(iSdpdb.Open(iSdp));
+
+ TSdpServRecordHandle handle;
+ iSdpdb.CreateServiceRecordL(TUUID(0x1105), handle);
+ iSdpdb.UpdateAttributeL(handle, 0x100, _L8("Obex push server"));
+
+
+ TSdpServRecordHandle ftphandle;
+ iSdpdb.CreateServiceRecordL(TUUID(0x1106), ftphandle);
+ iSdpdb.UpdateAttributeL(ftphandle, 0x100, _L8("File transfer server"));
+
+ // Protocol Descriptor List (same for both profiles)
+ iProtDescList = CSdpAttrValueDES::NewDESL(0);
+
+ iProtDescList
+ ->StartListL()
+ ->BuildDESL()
+ ->StartListL()
+ ->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
+ ->EndListL()
+ ->BuildDESL()
+ ->StartListL()
+ ->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
+ ->BuildUintL(TSdpIntBuf<TInt8>(transportInfo->iAddr.Port()))
+ ->EndListL()
+ ->BuildDESL()
+ ->StartListL()
+ ->BuildUUIDL(TUUID(TUint16(0x0008))) // OBEX
+ ->EndListL()
+ ->EndListL();
+
+ iSdpdb.UpdateAttributeL(handle, 4, *iProtDescList);
+ iSdpdb.UpdateAttributeL(ftphandle, 4, *iProtDescList); // put into both records
+ delete iProtDescList;
+ iProtDescList = NULL;
+
+ // Supported formats list (OPP only)
+ iProtDescList = CSdpAttrValueDES::NewDESL(0);
+
+ iProtDescList->StartListL()
+ ->BuildUintL(TSdpIntBuf<TUint8>(0xFF)) // Accept any type of object
+ ->EndListL();
+
+ iSdpdb.UpdateAttributeL(handle, 0x0303, *iProtDescList);
+
+ delete iProtDescList;
+ iProtDescList = NULL;
+
+ // Add OPP to the supported profiles list
+ iProtDescList = CSdpAttrValueDES::NewDESL(0);
+
+ iProtDescList->StartListL()
+ ->BuildDESL()
+ ->StartListL()
+ ->BuildUUIDL(TUUID(0x1105)) // OPP Profile
+ ->BuildUintL(TSdpIntBuf<TUint16>(0x0100)) // Profile version
+ ->EndListL()
+ ->EndListL();
+
+ iSdpdb.UpdateAttributeL(handle, 9, *iProtDescList); // profile list
+
+ delete iProtDescList;
+ iProtDescList = NULL;
+
+ // Add FTP to the supported profiles list
+ iProtDescList = CSdpAttrValueDES::NewDESL(0);
+
+ iProtDescList->StartListL()
+ ->BuildDESL()
+ ->StartListL()
+ ->BuildUUIDL(TUUID(0x1106)) // FTP Profile
+ ->BuildUintL(TSdpIntBuf<TUint16>(0x0100)) // Profile version
+ ->EndListL()
+ ->EndListL();
+
+ iSdpdb.UpdateAttributeL(ftphandle, 9, *iProtDescList); // profile list
+
+ delete iProtDescList;
+ iProtDescList = NULL;
+
+ // Set host name
+ RSocketServ ss;
+ ss.Connect();
+
+ RHostResolver hr;
+ User::LeaveIfError(hr.Open(ss,KBTAddrFamily,KBTLinkManager));
+ User::LeaveIfError(hr.SetHostName(_L("Symbian Push Server")));
+ ss.Close();
+
+ // Enable enquiry and page scan
+ User::LeaveIfError(RProperty::Set(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothSetScanningStatus, EInquiryAndPageScan));
+ }
+
+CObexServerHandlerBase::~CObexServerHandlerBase ()
+ {
+ Stop();
+
+ if (iTransportLayer == EBluetooth)
+ {
+ // security now cleared with socket closure
+ iSdpdb.Close();
+ iSdp.Close();
+ }
+#ifdef PACKET_ACCESS_EXTENSION
+ delete iPacketAccessUi;
+#endif // PACKET_ACCESS_EXTENSION
+
+#ifdef ASYNC_INDICATION
+ delete iServerAsyncAO;
+#endif
+ delete iServer;
+ delete iProtDescList;
+ }
+
+void CObexServerHandlerBase::RemoteAddress()
+ {
+ TSockAddr aAddr;
+ iServer->RemoteAddr( aAddr);
+ TBTDevAddr addr = static_cast <TBTSockAddr>(aAddr).BTAddr();
+
+ TChar aChar;
+
+ iParent->Console()->Printf(_L("Remote Address = "));
+ for(TInt count = 0; count < addr.Des().Length(); count++)
+ {
+ aChar = (addr.Des()[count] & 0xf0)>>4;
+ if (aChar <= 9)
+ aChar += 0x30;
+ else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+ aChar += 'A' - 0x0a;
+ iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+ aChar = (addr.Des()[count] & 0x0f);
+ if (aChar <= 9)
+ aChar += 0x30;
+ else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+ aChar += 'A' - 0x0a;
+ iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+ }
+ iParent->Console()->Printf(_L("\r\n"));
+ }
+
+
+void CObexServerHandlerBase::Start()
+ {
+ if (iServer)
+ {
+ iServer->Start(this);
+ }
+ }
+
+void CObexServerHandlerBase::Stop()
+ {
+ if (iServer)
+ {
+ iServer->Stop();
+ }
+ }
+
+void CObexServerHandlerBase::SetTargetChecking(CObexServer::TTargetChecking aValue)
+ {
+ iServer->SetTargetChecking(aValue);
+ }
+
+
+
+// MObexServerNotify interface functions
+
+void CObexServerHandlerBase::ErrorIndication (TInt aError)
+ {
+ iParent->Console()->Printf(_L("Obex Server Error: %d\r\n"), aError);
+ }
+
+void CObexServerHandlerBase::TransportUpIndication ()
+ {
+ iParent->Console()->Printf(_L("\r\nTransport layer now connected\r\n\r\n"));
+ }
+
+void CObexServerHandlerBase::TransportDownIndication ()
+ {
+ iParent->Console()->Printf(_L("\r\nTransport layer has gone down\r\n\r\n"));
+
+ if (iObject)
+ {
+ if(!iObject->BytesReceived())
+ {
+ return;
+ }
+
+ iParent->Console()->Printf(_L("\r\nWe have received part of an Obex object\r\n\r\n"));
+
+ iObject->Reset();//close file handle
+ }
+ }
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& /*aInfo*/)
+#else
+TInt CObexServerHandlerBase::ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& /*aInfo*/)
+#endif
+ {
+ iParent->Console()->Printf(_L("\r\nCObexServerHandler::ObexConnectIndication"));
+ iParent->Console()->Printf(_L("\r\nConnected to machine with OBEX version %d.%d\r\n"),
+ aRemoteInfo.VersionMajor (), aRemoteInfo.VersionMinor ());
+
+ if ( aRemoteInfo.iWho.Length() > 0 )
+ {
+ iParent->Console()->Printf(_L("EWho received from remote side ="));
+
+ for(TInt count = 0; count < aRemoteInfo.iWho.Length(); count++)
+ {
+
+ TChar aChar;
+
+ aChar = (aRemoteInfo.iWho[count] & 0xf0)>>4;
+ if (aChar <= 9)
+ aChar += 0x30;
+ else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+ aChar += 'A' - 0x0a;
+ iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+ aChar = (aRemoteInfo.iWho[count] & 0x0f);
+ if (aChar <= 9)
+ aChar += 0x30;
+ else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+ aChar += 'A' - 0x0a;
+ iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+ }
+ iParent->Console()->Printf(_L("\r\n"));
+ }
+ else
+ iParent->Console()->Printf(_L("No Who Header received\r\n"));
+
+ if ( aRemoteInfo.iTargetHeader.Length() > 0 )
+ {
+ iParent->Console()->Printf(_L("ETarget received from remote side ="));
+ for(TInt count = 0; count < aRemoteInfo.iTargetHeader.Length(); count++)
+ {
+ TChar aChar;
+
+ aChar = (aRemoteInfo.iTargetHeader[count] & 0xf0)>>4;
+ if (aChar <= 9)
+ aChar += 0x30;
+ else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+ aChar += 'A' - 0x0a;
+ iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+
+ aChar = (aRemoteInfo.iTargetHeader[count] & 0x0f);
+ if (aChar <= 9)
+ aChar += 0x30;
+ else if ((aChar >= 0x0a) && (aChar <= 0x0f))
+ aChar += 'A' - 0x0a;
+ iParent->Console()->Printf(_L("%C"),(TUint)aChar);
+ }
+ iParent->Console()->Printf(_L("\r\n"));
+ }
+ else
+ iParent->Console()->Printf(_L("No Target Header received\r\n"));
+
+#ifndef ASYNC_INDICATION
+ return KErrNone;
+#endif
+ }
+
+void CObexServerHandlerBase::ObexDisconnectIndication (const TDesC8& /*aInfo*/)
+ {
+ iParent->Console()->Printf(_L("\r\nObex Disconnected\r\n\r\n"));
+ }
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::PutRequestIndication ()
+#else
+CObexBufObject* CObexServerHandlerBase::PutRequestIndication ()
+#endif
+ {
+ iStartTime.HomeTime();
+
+ iParent->Console()->Printf(_L("Receiving object...\r\n"));
+ iObject->Reset ();
+#ifdef ASYNC_INDICATION
+ iServerAsyncAO->RequestIndication(CObex::EOpPut, iAcceptPuts?iObject:NULL);
+#else
+ return iAcceptPuts?iObject:NULL;
+#endif
+ }
+
+TInt CObexServerHandlerBase::PutPacketIndication ()
+ {
+ // Only output % received if performance logging is disabled.
+ if(!iParent->iPerformanceLoggingEnabled)
+ {
+ TUint length = iObject->Length();
+ TUint received = iObject->BytesReceived();
+ TUint8 percent = 0;
+ if (length > 0)
+ {
+ percent = TUint8((100 * received) / length);
+ iParent->Console()->Printf(_L("\r%d %% "), percent);
+ }
+ else
+ {
+ iParent->Console()->Printf(_L("\r%d Bytes "), iObject->BytesReceived ());
+ }
+ }
+ return (KErrNone);
+ }
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::PutCompleteIndication()
+#else
+TInt CObexServerHandlerBase::PutCompleteIndication()
+#endif
+ {
+ TTime finishTime;
+ finishTime.HomeTime();
+ TTimeIntervalMicroSeconds diff = finishTime.MicroSecondsFrom(iStartTime);
+
+ iParent->Console()->Printf(_L("\nObject Received in %d"), diff.Int64());
+
+ TPtrC name=iObject->Name();
+ TBuf<100> type;
+ type.Copy(iObject->Type());
+ iParent->Console()->Printf(_L("\r\nSuccessfully received '%S'\r\nType[%d]: '%S'\r\n"), &name, type.Length(), &type);
+
+ TInt err = KErrNone;
+ if (iParent->DisplayHeaders())
+ {
+ // No need to put header on the cleanup stack, as there are no leaving functions during its lifetime
+ CObexHeader* header = NULL;
+ TRAP(err, header = CObexHeader::NewL());
+ if (err)
+ {
+ iParent->iConsole->Printf(_L("Error allocating memory to display\r\n"));
+ }
+
+ iObject->HeaderSet().SetMask(NULL);
+ iObject->HeaderSet().First();
+
+ while (err == KErrNone)
+ {
+ err = iObject->HeaderSet().This(header);
+
+ switch (header->Type())
+ {
+ case (0x00): //Unicode
+ {
+ HBufC16* buf = NULL;
+ TRAPD(headerErr, buf = HBufC16::NewL((header->AsUnicode()).Size()));
+ if (headerErr)
+ {
+ iParent->iConsole->Printf(_L("Unicode Header (0x%x)- Error allocating memory to display\r\n"), header->HI());
+ }
+ else
+ {
+ TPtr16 type(buf->Des());
+ type.Copy(header->AsUnicode());
+
+ iParent->iConsole->Printf(_L("Unicode Header (0x%x) = : \"%S\"\r\n"), header->HI(), &type);
+ delete buf;
+ }
+ break;
+ }
+ case (0x01): // ByteSeq
+ {
+ HBufC16* buf = NULL;
+ TRAPD(headerErr, buf = HBufC16::NewL((header->AsByteSeq()).Size()));
+ if (headerErr)
+ {
+ iParent->iConsole->Printf(_L("ByteSeq Header (0x%x)- Error allocating memory to display\r\n"), header->HI());
+ }
+ else
+ {
+ TPtr16 type(buf->Des());
+ type.Copy(header->AsByteSeq());
+
+ iParent->iConsole->Printf(_L("ByteSeq Header (0x%x) = : \"%S\"\r\n"), header->HI(), &type);
+ delete buf;
+ }
+ break;
+ }
+ case (0x02): // Byte
+ {
+ iParent->iConsole->Printf(_L("Byte Header (0x%x) = : 0x%x\r\n"), header->HI(), header->AsByte());
+ break;
+ }
+ case (0x03): //FourByte
+ {
+ iParent->iConsole->Printf(_L("FourByte Header (0x%x) = : 0x%x\r\n"), header->HI(), header->AsFourByte());
+ break;
+ }
+ default : {break;}
+ }
+
+ err = iObject->HeaderSet().Next();
+ }
+
+ delete header;
+ }
+
+ TDateTime dt = iObject->Time().DateTime();
+ iParent->Console()->Printf(_L("\r\nTimestamp: %d/%d/%d, %d:%d:%d\r\n\r\n"),
+ dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour(), dt.Minute(), dt.Second());
+
+ // Reset err to no error;
+ err = KErrNone;
+
+ if ((iObject->Name() == KRef1Name) ||
+ (iObject->Name() == KRef2Name) ||
+ (iObject->Name() == KRef3Name) ||
+ (iObject->Name() == KRef4Name) ||
+ (iObject->Name() == KRef5Name) ||
+ (iObject->Name() == KRef6Name) ||
+ (iObject->Name() == KRef7Name) ||
+ (iObject->Name() == KRef8Name) ||
+ (iObject->Name() == KRef9Name))
+ {
+ iParent->Console()->Printf(_L("\r\nReference Object Received"));
+ TInt objComp = 0;
+ TRAP(err, objComp = iParent->iRefHandler->CompareObjectToReferenceL(*iObject, *iBuf, iParent->iTransport));
+ if ((objComp != 0) || (err != KErrNone)) // Make sure the objects match
+ {
+ User::Panic(_L("TOBEX - OBJCOMP"), err);
+ }
+ iParent->Console()->Printf(_L("\r\nReference Object Comparison OK\r\n\r\n"));
+ }
+ else
+ {
+ iParent->Console()->Printf(_L("Size of received object = %d\n"),iBuf->Size());
+
+ // Only output packet contents info if performance logging is disabled.
+ if(!iParent->iPerformanceLoggingEnabled)
+ {
+ TBuf8<1024> tempBuffer;
+ iBuf->Read(0, tempBuffer, tempBuffer.MaxSize() < iBuf->Size() ? tempBuffer.MaxSize() : iBuf->Size());
+
+ // Printf fails with Descriptor beigger than X hundred bytes so write byte at a time
+ for(TInt count = 0; count < tempBuffer.Size(); count++)
+ {
+ iParent->Console()->Printf(_L("%C"),tempBuffer[count]);
+ }
+ }
+
+ if (iObject->Name() != KNullDesC )
+ {
+ TFileName filename;
+ filename = iParent->iInboxRoot;
+
+ TInt bufSpaceLeft = filename.MaxLength() - filename.Length();
+ TInt objNameLen = iObject->Name().Length();
+ TInt numToCopy = objNameLen;
+ if (bufSpaceLeft < objNameLen)
+ {
+ numToCopy = bufSpaceLeft;
+ iParent->Console()->Printf(_L("Truncated resulting local filename\n"));
+ }
+ filename.Append(iObject->Name().Ptr(), numToCopy);
+
+ err = iObject->WriteToFile(filename);
+
+ if (err == KErrAlreadyExists)
+ {
+ iParent->Console()->Printf(_L("\r\nWrite failed, File Already Exists\n"));
+ }
+ else if (err != KErrNone)
+ {
+ iParent->Console()->Printf(_L("\r\nWrite failed with error %d\n"), err);
+ }
+ }
+ else
+ {
+ err = KErrNone;
+ iParent->Console()->Printf(_L("\r\nReceived object with empty Name Header.\nNot writing to a file\n"));
+ }
+ }
+
+ TObexHeaderMask headers = iObject->ValidHeaders();
+ iParent->Console()->Printf(_L("\n"));
+ if (headers & KObexHdrBody)
+ iParent->Console()->Printf(_L("Body header received\n"));
+ if (headers & KObexHdrEndOfBody)
+ iParent->Console()->Printf(_L("EndOfBody header received\n"));
+
+ iObject->Reset ();
+#ifdef ASYNC_INDICATION
+ if(err)
+ {
+ iServerAsyncAO->CompletionIndication(CObex::EOpPut, ERespNotAcceptable);
+ }
+ else
+ {
+ iServerAsyncAO->CompletionIndication(CObex::EOpPut, ERespSuccess);
+ }
+
+#else
+ return err;
+#endif
+ }
+
+void CObexServerHandlerBase::HandleGetReferenceObjL(CObexBaseObject* aRequiredObject)
+ {
+ CObexBufObject& obj = *static_cast<CObexBufObject*>(aRequiredObject);
+ CBufFlat* dummyBufPtr = CBufFlat::NewL(0);
+ CleanupStack::PushL(dummyBufPtr);
+
+ // See if what we got in the Get request is the same as the reference object...
+ TInt objComp = iParent->iRefHandler->CompareObjectToReferenceL(obj, *dummyBufPtr, iParent->iTransport);
+ CleanupStack::PopAndDestroy(dummyBufPtr);
+ ASSERT(objComp == CReferenceHandler::EDifferentBuf);
+
+ // Everythings OK so set up the reference object to be returned
+ iParent->Console()->Printf(_L("Obex Get Reference Object Request\r\n"));
+
+
+ if (aRequiredObject->Name() == KRef1Name)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 1, iParent->iTransport);
+ else if (aRequiredObject->Name() == KRef2Name)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 2, iParent->iTransport);
+ else if (aRequiredObject->Name() == KRef3Name)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 3, iParent->iTransport);
+ else if (aRequiredObject->Name() == KRef4Name)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 4, iParent->iTransport);
+ else if (aRequiredObject->Name() == KRef5Name)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 5, iParent->iTransport);
+ else if (aRequiredObject->Name() == KRef6Name)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 6, iParent->iTransport);
+ else if (aRequiredObject->Name() == KRef7Name)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 7, iParent->iTransport);
+ else if (aRequiredObject->Name() == KRef8Name)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 8, iParent->iTransport);
+ else if (aRequiredObject->Name() == KRef9Name)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 9, iParent->iTransport);
+ else // capture error condition (use reference 1)
+ iParent->iRefHandler->CreateReferenceL(*iObject, *iBuf, 1, iParent->iTransport);
+
+ }
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::GetRequestIndication (CObexBaseObject* aRequiredObject)
+#else
+CObexBufObject* CObexServerHandlerBase::GetRequestIndication (CObexBaseObject* aRequiredObject)
+#endif
+ {
+ //check if app params header sent across
+ if ( aRequiredObject->ValidHeaders() & KObexHdrAppParam )
+ {
+ TBuf<30> localBuf;
+ localBuf.Copy(aRequiredObject->AppParam());
+
+ iParent->iConsole->Printf(_L(" App Param received = : %S\r\n"), &localBuf);
+ }
+ else
+ {
+ iParent->iConsole->Printf(_L(" No App Param Headers received\r\n"));
+ }
+
+ //check if any HTTP headers were sent across
+ if ( aRequiredObject->ValidHeaders() & KObexHdrHttp)
+ {
+ //OK so lets get them out
+ const RPointerArray<HBufC8>* localHttpArray = aRequiredObject->Http();
+ //how many?
+ TInt count = localHttpArray->Count();
+ HBufC8* localArray;
+ TBuf8<30> localBuf;
+ TBuf<40> buf;
+ TInt size = 30;
+ for ( TInt x = 0; x < count; x++ )
+ {
+ localArray = (*localHttpArray)[x];
+ size = Max(localArray->Size(), 30);
+ localBuf.Copy(localArray->Ptr(), size);
+ buf.Copy(localBuf);
+ iParent->iConsole->Printf(_L(" HTTP Header Received : %S\r\n"), &buf);
+ }
+ }
+ else
+ {
+ iParent->iConsole->Printf(_L(" No HTTP Headers received\r\n"));
+ }
+
+ if ((aRequiredObject->Name() == KRef1Name) ||
+ (aRequiredObject->Name() == KRef2Name) ||
+ (aRequiredObject->Name() == KRef3Name) ||
+ (aRequiredObject->Name() == KRef4Name) ||
+ (aRequiredObject->Name() == KRef5Name) ||
+ (aRequiredObject->Name() == KRef6Name) ||
+ (aRequiredObject->Name() == KRef7Name) ||
+ (aRequiredObject->Name() == KRef8Name) ||
+ (aRequiredObject->Name() == KRef9Name))
+ {
+#ifdef _DEBUG
+ TRAPD(err, HandleGetReferenceObjL(aRequiredObject));
+ ASSERT(err==0);
+#else
+ TRAP_IGNORE(HandleGetReferenceObjL(aRequiredObject));
+#endif
+ }
+ else
+ {
+ TRAPD(err,SetUpGetObjectL(aRequiredObject));
+ if (err != KErrNone)
+ {
+ iParent->Console()->Printf(_L("\nSetUpGetObjectL() returned %d.\n"), err);
+#ifdef ASYNC_INDICATION
+ iServerAsyncAO->RequestIndication(CObex::EOpGet, NULL);
+#else
+ iServer->RequestIndicationCallbackWithError(err); //added to test PDEF097129
+ return (NULL);
+#endif
+ }
+ }
+#ifdef ASYNC_INDICATION
+ iServerAsyncAO->RequestIndication(CObex::EOpGet, iObject);
+#else
+ return (iObject);
+#endif
+ }
+
+TInt CObexServerHandlerBase::GetPacketIndication ()
+ {
+ if (iObject->Length () > 0)
+ {
+ TInt percentComplete = 100 * iObject->BytesSent () / iObject->Length ();
+ iParent->Console()->Printf(_L("\r%d %% "), percentComplete);
+ }
+ else
+ {
+ iParent->Console()->Printf(_L("\r%d Bytes "), iObject->BytesSent ());
+ }
+
+ return (KErrNone);
+ }
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::GetCompleteIndication ()
+#else
+TInt CObexServerHandlerBase::GetCompleteIndication ()
+#endif
+ {
+ iParent->Console()->Printf(_L("Obex Get Complete\r\n"));
+ iObject->Reset ();
+#ifdef ASYNC_INDICATION
+ iServerAsyncAO->CompletionIndication(CObex::EOpGet, ERespSuccess);
+#else
+ return KErrNone;
+#endif
+ }
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::SetPathIndication (const CObex::TSetPathInfo& aPathInfo, const TDesC8& /*aInfo*/)
+#else
+TInt CObexServerHandlerBase::SetPathIndication (const CObex::TSetPathInfo& aPathInfo, const TDesC8& /*aInfo*/)
+#endif
+ {
+ iParent->Console()->Printf(_L("Obex SetPath request:\r\n"));
+ iParent->Console()->Printf(_L(" --- Flags = '%d' - Constants = '%d' - "), aPathInfo.iFlags, aPathInfo.iConstants);
+ if (aPathInfo.iNamePresent)
+ iParent->Console()->Printf(_L("Name = %S\r\n"), &aPathInfo.iName);
+ else
+ iParent->Console()->Printf(_L("> No Name Present <\r\n"));
+
+ iParent->Console()->Printf(_L("\nReturning success...!\n"));
+#ifdef ASYNC_INDICATION
+ iServerAsyncAO->CompletionIndication(CObex::EOpSetPath, ERespSuccess);
+#else
+ return (KErrNone);
+#endif
+ }
+
+void CObexServerHandlerBase::AbortIndication ()
+ {
+ iParent->Console()->Printf(_L("Obex Operation aborted\r\n"));
+ if(iObject)
+ {
+ if(!iObject->BytesReceived())
+ return;
+ iParent->Console()->Printf(_L("\r\nWe have received part of an Obex object\r\n\r\n"));
+
+ iObject->Reset();//closes file handle
+ }
+ }
+
+void CObexServerHandlerBase::MoraoReadActivity()
+ {
+ iParent->Console()->Printf(_L("Obex Server: 'Read Activity' signalled\r\n"));
+ }
+
+void CObexServerHandlerBase::SetUpGetObjectL(CObexBaseObject *aRequestedObject)
+ {
+ TFileName name;
+ name = iParent->iInboxRoot;
+ name.Append(aRequestedObject->Name ());
+ if(name.Length())
+ {
+ iParent->Console()->Printf(_L("Obex Get Request for name '%s'\r\n"), name.PtrZ ());
+ }
+ else if (aRequestedObject->Type().Length())
+ {
+ name = iParent->iInboxRoot;
+ TBuf<32> temp;
+ temp.Copy(aRequestedObject->Type());
+ name.Append(temp);
+ iParent->Console()->Printf(_L("Obex Get Request for type '%s'\r\n"), name.PtrZ ());
+ TInt pos;
+ while((pos=name.Locate('/')) >= 0)
+ name[pos] = '_';
+ pos=name.Length()-1;
+ if(pos>=0 && name[pos] == 0)
+ name.SetLength(pos); // Work around last character possibly being NULL
+ }
+ else
+ {
+ iParent->Console()->Printf(_L("Obex Get Request unknown details\r\n"));
+ User::Leave(KErrNotSupported);
+ }
+ iObject->Reset();
+
+ RFs fs;
+ RFile f;
+ if ((fs.Connect () != KErrNone) ||
+ (f.Open (fs, name, EFileShareReadersOnly | EFileRead) != KErrNone))
+ {
+ iParent->Console()->Printf(_L("\r\nError reading '%S'."), &name);
+ User::Leave(KErrNotFound);
+ }
+
+ TInt size = 0;
+ User::LeaveIfError(f.Size (size));
+ iBuf->ResizeL(size);
+ TPtr8 data (iBuf->Ptr(0));
+ f.Read (data);
+ if (iBuf->Size() < size)
+ User::Leave(KErrGeneral);
+ iObject->SetNameL(name);
+ iObject->SetLengthL(size);
+ TTime time;
+ if (f.Modified(time) == KErrNone)
+ iObject->SetTimeL(time);
+ }
+
+void CObexServerHandlerBase::EnableAuthentication()
+ {
+ TRAPD(err, iServer->SetChallengeL(iChallengePassword));
+ if (err == KErrNone)
+ {
+ iIsAuthenticationEnabled = ETrue;
+ }
+ else
+ {
+ iParent->iConsole->Printf(_L("Failed to set authentication password\r\n"));
+ }
+ }
+
+void CObexServerHandlerBase::DisableAuthentication()
+ {
+ iServer->ResetChallenge();
+ iIsAuthenticationEnabled = EFalse;
+ }
+
+void CObexServerHandlerBase::EnablePassword()
+ {
+ iServer->SetCallBack(*this);
+ }
+
+void CObexServerHandlerBase::ChangeChallengePassword(TDesC* aPassword)
+ {
+ if (aPassword)
+ iChallengePassword = *aPassword;
+ else
+ iParent->SetPassword(iChallengePassword);
+
+ if (iIsAuthenticationEnabled)
+ {
+ DisableAuthentication();
+ EnableAuthentication();
+ }
+ }
+
+void CObexServerHandlerBase::ChangeResponsePassword()
+ {
+ iParent->Cancel();
+ iParent->SetPassword(iResponsePassword);
+ iParent->RequestCharacter(); // re-request, to re-display menu
+ }
+
+void CObexServerHandlerBase::GetUserPasswordL(const TDesC& aUserID)
+ {
+ iParent->Console()->Printf(_L("\r\nServer has been challenged by %S"), &aUserID);
+ ChangeResponsePassword(); //get the password from user
+ iServer->UserPasswordL(iResponsePassword);
+ }
+
+void CObexServerHandlerBase::SetLocalWho()
+ {
+ iServer->SetLocalWho(KRefTarget);
+ }
+
+#ifdef ASYNC_INDICATION
+void CObexServerHandlerBase::CancelIndicationCallback()
+ {
+ iServerAsyncAO->Cancel();
+ }
+#endif
+
+#ifdef PACKET_ACCESS_EXTENSION
+void CObexServerHandlerBase::PacketAccessUiL(TBool aEnable)
+ {
+ if (aEnable)
+ {
+ iPacketAccessUi = CObexServerPacketAccessUi::NewL(*this, *iServer);
+ }
+ else
+ {
+ delete iPacketAccessUi;
+ iPacketAccessUi = NULL;
+ }
+ }
+#endif // PACKET_ACCESS_EXTENSION
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandlerbase.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,137 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef _SERVERHANDLERBASE_H
+#define _SERVERHANDLERBASE_H
+
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+#include <obexreadactivityobserver.h>
+#include "constants.h"
+
+class CServerAsyncAO;
+class CActiveConsole;
+class CObexServerPacketAccessUi;
+
+
+class CObexServerHandlerBase : public CBase,
+#ifdef ASYNC_INDICATION
+ private MObexServerNotifyAsync,
+#else
+ private MObexServerNotify,
+#endif
+ public MObexAuthChallengeHandler,
+
+ public MObexReadActivityObserver
+//-----------------------------------------------------------
+ {
+public:
+ // Construction
+ void BaseConstructL(TTransport aTransport);
+
+ void Start();
+ void Stop();
+ // Destruction
+ virtual ~CObexServerHandlerBase();
+
+ void EnableAuthentication();
+ void DisableAuthentication();
+ void EnablePassword();
+ void ChangeChallengePassword(TDesC* aPassword = NULL);
+ void ChangeResponsePassword();
+ void SetLocalWho();
+ void SetTargetChecking(CObexServer::TTargetChecking aValue);
+ void GetUserPasswordL(const TDesC& aUserID);
+ void RemoteAddress();
+#ifdef PACKET_ACCESS_EXTENSION
+ void PacketAccessUiL(TBool aEnable);
+#endif // PACKET_ACCESS_EXTENSION
+
+protected:
+ CObexServerHandlerBase(CActiveConsole* aParent);
+
+private:
+ // Implementation of MObexServerNotify interface
+ virtual void ErrorIndication (TInt aError);
+ virtual void TransportUpIndication ();
+ virtual void TransportDownIndication ();
+
+ virtual void ObexDisconnectIndication (const TDesC8& aInfo);
+ virtual TInt PutPacketIndication ();
+ virtual TInt GetPacketIndication ();
+ virtual void AbortIndication ();
+
+
+#ifdef ASYNC_INDICATION
+ void GetCompleteIndication ();
+ void PutCompleteIndication ();
+ void SetPathIndication (const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo);
+ void CancelIndicationCallback();
+ void ObexConnectIndication (const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo);
+ void PutRequestIndication ();
+ void GetRequestIndication (CObexBaseObject *aRequestedObject);
+#else
+ TInt ObexConnectIndication (const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo);
+ TInt GetCompleteIndication ();
+ TInt PutCompleteIndication ();
+ TInt SetPathIndication (const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo);
+ CObexBufObject* PutRequestIndication ();
+ CObexBufObject* GetRequestIndication (CObexBaseObject *aRequestedObject);
+#endif
+
+ // Implementation of MObexReadActivityObserver interface
+ void MoraoReadActivity();
+ void SetUpGetObjectL(CObexBaseObject *aRequestedObject);
+ void HandleGetReferenceObjL(CObexBaseObject* aRequiredObject);
+
+ void InitBluetoothL();
+
+public:
+ TBuf<16> iChallengePassword;
+ TBuf<16> iResponsePassword;
+ TBool iAcceptPuts;
+
+protected:
+ CObexBufObject* iObject;
+ CBufFlat* iBuf;
+ CActiveConsole* iParent;
+
+private:
+ CObexServer* iServer;
+ TBool iIsAuthenticationEnabled;
+ TTransport iTransportLayer;
+ CSdpAttrValueDES* iProtDescList;
+ RSdp iSdp;
+ RSdpDatabase iSdpdb;
+#ifdef ASYNC_INDICATION
+ CServerAsyncAO* iServerAsyncAO;
+#endif
+#ifdef PACKET_ACCESS_EXTENSION
+ CObexServerPacketAccessUi* iPacketAccessUi;
+#endif // PACKET_ACCESS_EXTENSION
+
+ TTime iStartTime;
+ };
+
+#endif // _SERVERHANDLERBASE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandlerfile.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,110 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include <ir_sock.h>
+#include <bautils.h>
+#include <usbman.h>
+#include <d32usbc.h>
+#include "serverhandlerbase.h"
+#include "serverhandlerfile.h"
+#include "TOBEXCON.H"
+#include "btextnotifiers.h"
+
+#define EPOCIDENT _L8("EPOC32 ER5")
+
+
+CObexServerHandlerFile::CObexServerHandlerFile(CActiveConsole* aParent)
+ : CObexServerHandlerBase(aParent)
+ {
+ }
+
+CObexServerHandlerFile* CObexServerHandlerFile::NewL(CActiveConsole* aParent, TTransport aTransport, TBool aUseRFile)
+ {
+ CObexServerHandlerFile* self = new (ELeave) CObexServerHandlerFile(aParent);
+
+ CleanupStack::PushL(self);
+ self->ConstructL(aTransport, aUseRFile);
+ CleanupStack::Pop();
+ return (self);
+ }
+
+void CObexServerHandlerFile::ConstructL(TTransport aTransport, TBool aUseRFile)
+ {
+ BaseConstructL(aTransport);
+
+ iUseRFile = aUseRFile;
+
+ iBuf = CBufFlat::NewL(10);//Was 5000, reduced to force more writes to file
+
+ // Required to configure buffer for memory backed file writes
+ iBuf->ResizeL(10); //was 5000
+
+ // New style construction
+ iObject = CObexBufObject::NewL(NULL);
+
+ if(!iUseRFile)
+ {
+ iBuffering = ETrue;
+
+ iObject->SetDataBufL(static_cast<const TDesC>(KFileName), iBuf);
+ }
+ else
+ {
+ //Create the RFile to be used
+ User::LeaveIfError(iFs.Connect());
+ iFs.Delete(KRFileTestFileName); //Try deleting the file, in case it wasn't cleaned up previously.
+ User::LeaveIfError(iFile.Create(iFs,KRFileTestFileName,EFileWrite));
+ iParent->Console()->Printf(_L("\r\nCreated RFile '%S'\r\n"),&KRFileTestFileName);
+
+ //Create a TObexRFileBackedBuffer object
+ TObexRFileBackedBuffer details(*iBuf,iFile,CObexBufObject::ESingleBuffering);
+
+ //Call CObexBufObject::SetDataBuf
+ iObject->SetDataBufL(details);
+ }
+
+ iParent->Console()->Printf(_L("\r\nStarting server\r\n"));
+ }
+
+CObexServerHandlerFile::~CObexServerHandlerFile ()
+ {
+ delete iObject; iObject = 0;
+ delete iBuf; iBuf = 0;
+
+ if(iUseRFile)
+ {
+ //Clean up the RFile we created for this test
+ //File will already have been closed by obex.
+ iFs.Delete(KRFileTestFileName);
+ iFs.Close();
+ }
+ }
+
+void CObexServerHandlerFile::ToggleWriteBuffering()
+ {
+ iBuffering = !iBuffering;
+
+ if (iBuffering)
+ {
+ iParent->Console()->Printf(_L("Enabling buffering...\r\n"));
+ iObject->SetDataBufL(static_cast<const TDesC>(KFileName), iBuf);//Qualified
+ }
+ else
+ {
+ iParent->Console()->Printf(_L("Disabling buffering...\r\n"));
+ iObject->SetDataBufL(static_cast<const TDesC>(KFileName));//Qualified
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverhandlerfile.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,56 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef _SERVERHANDLERFILE_H
+#define _SERVERHANDLERFILE_H
+
+#include <es_sock.h>
+#include <e32test.h>
+#include <es_prot.h>
+#include <e32cons.h>
+#include <obex.h>
+#include <btmanclient.h>
+#include <obex/internal/obexinternalheader.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <btsdp.h>
+#include <obexfinalpacketobserver.h>
+
+class CActiveConsole;
+
+class CObexServerHandlerFile : public CObexServerHandlerBase
+//-----------------------------------------------------------
+ {
+public:
+ // Construction
+ static CObexServerHandlerFile* NewL(CActiveConsole* aParent, TTransport aTransport, TBool aUseRFile=EFalse);
+ void ConstructL(TTransport aTransport, TBool aUseRFile);
+ ~CObexServerHandlerFile();
+
+ void ToggleWriteBuffering();
+
+private:
+ CObexServerHandlerFile(CActiveConsole* aParent);
+
+private:
+ TBool iUseRFile;
+ RFs iFs;
+ RFile iFile;
+ TBool iBuffering;
+ };
+
+
+
+
+#endif // _SERVERHANDLERFILE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverpacketaccessui.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,456 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "serverpacketaccessui.h"
+
+#include <e32cons.h>
+#include <obex/extensionapis/obexserverpacketaccessextension.h>
+#include <obexserver.h>
+#include <obexheaders.h>
+#include "serverhandlerbase.h"
+
+
+CObexServerPacketAccessUi* CObexServerPacketAccessUi::NewL(CObexServerHandlerBase& aHandler, CObexServer& aServer)
+ {
+ CObexServerPacketAccessUi* self = new (ELeave) CObexServerPacketAccessUi(aHandler, aServer);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CObexServerPacketAccessUi::~CObexServerPacketAccessUi()
+ {
+ Cancel();
+
+ delete iPacketAccess;
+ delete iConsole;
+ }
+
+CObexServerPacketAccessUi::CObexServerPacketAccessUi(CObexServerHandlerBase& aHandler, CObexServer& aServer)
+ : CActive(EPriorityNormal), iHandler(aHandler), iServer(aServer)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+void CObexServerPacketAccessUi::ConstructL()
+ {
+ TRAPD(err, iConsole = Console::NewL(_L("Request Packets"),TSize(50,40)));
+ if (err != KErrNone)
+ {
+ TRAPD(err, iConsole = Console::NewL(_L("Request Packets"),TSize(50,15)));
+ if (err != KErrNone)
+ {
+ // we had a problem creating the console, probably because it was too big
+ // so try again and make it full screen. If we leave this time then just
+ // go with it.
+ iConsole = Console::NewL(_L("Request Packets"),TSize(KConsFullScreen,KConsFullScreen));
+ }
+ }
+ iPacketAccess = CObexServerPacketAccessExtension::NewL(iServer, *this);
+
+ SetKeypressActive();
+ }
+
+void CObexServerPacketAccessUi::RunL()
+ {
+ TRAPD(err, ProcessKeyPressL(TChar(iConsole->KeyCode())));
+ if(err != KErrNone)
+ {
+ iConsole->Printf(_L("Error: %d\r\n"),err);
+ }
+ SetKeypressActive();
+ }
+
+void CObexServerPacketAccessUi::DoCancel()
+ {
+ iConsole->ReadCancel();
+ }
+
+void CObexServerPacketAccessUi::SetKeypressActive()
+ {
+ iConsole->Read(iStatus);
+ SetActive();
+ }
+
+void CObexServerPacketAccessUi::ProcessKeyPressL(TChar aChar)
+ {
+ if (aChar == EKeyEscape)
+ {
+ iHandler.PacketAccessUiL(EFalse);
+ return;
+ }
+
+ switch (aChar)
+ {
+ case 'E': case 'e': // Enable
+ {
+ delete iPacketAccess;
+ iPacketAccess = CObexServerPacketAccessExtension::NewL(iServer, *this);
+ }
+ break;
+ case 'D': case 'd': // Disable
+ {
+ delete iPacketAccess;
+ iPacketAccess = NULL;
+ }
+ break;
+ case 'I': case 'i': // Interactive mode toggle
+ {
+ iInteractive = !iInteractive;
+ }
+ break;
+ default:
+ {
+ iConsole->Printf(_L("Invalid Key - valid keys 'e','d','i','Esc'\r\n"));
+ }
+ break;
+ }
+ }
+
+TBool CObexServerPacketAccessUi::RequestPacket(TObexRequestCode aRequest, TObexResponse& aResponse)
+ {
+ TBool requestPacketResult(ETrue);
+
+ iConsole->Printf(_L("Request code %d\r\n"), aRequest);
+
+ // Use Packet Headers now
+ CObexHeaderSet* headerSet = NULL;
+ iServer.PacketHeaders(headerSet);
+ if (headerSet)
+ {
+ // Ensures that if the function leaves then the only option is to
+ // report a false operation. As RequestPacket function signiture is published partner
+ TRAPD(err,PrintHeadersL(*headerSet));
+ if (err != KErrNone)
+ {
+ requestPacketResult = EFalse;
+ }
+ delete headerSet;
+ }
+
+ if (requestPacketResult)
+ {
+ requestPacketResult = RequestPacketReturn(aResponse);
+ }
+
+ // Provide function result to caller
+ return requestPacketResult;
+ }
+
+TBool CObexServerPacketAccessUi::RequestPacket(TObexRequestCode aRequest, TObexConnectInfo& aConnectInfo, TObexResponse& aResponse)
+ {
+ TBool requestPacketResult(ETrue);
+
+ iConsole->Printf(_L("Request code %d - Connect\r\n"), aRequest);
+ iConsole->Printf(_L("\tMajor version=%d, Minor version=%d\r\n"), aConnectInfo.VersionMajor(), aConnectInfo.VersionMinor());
+ iConsole->Printf(_L("\tConnection flags=0x%02x\r\n"), aConnectInfo.iFlags);
+ if (aConnectInfo.iWho.Length() > 0)
+ {
+ iConsole->Printf(_L("\tWho attribute=%S\r\n"), &(aConnectInfo.iWho));
+ }
+ if (aConnectInfo.iTargetHeader.Length() > 0)
+ {
+ iConsole->Printf(_L("\tTarget header=%S\r\n"), &(aConnectInfo.iTargetHeader));
+ }
+
+ // Use Packet Headers now
+ CObexHeaderSet* headerSet = NULL;
+ iServer.PacketHeaders(headerSet);
+ if (headerSet)
+ {
+ // Ensures that if the function leaves then the only option is to
+ // report a false operation. As RequestPacket function signiture is published partner
+ TRAPD(err,PrintHeadersL(*headerSet));
+ if (err != KErrNone)
+ {
+ requestPacketResult = EFalse;
+ }
+ delete headerSet;
+ }
+
+ if (requestPacketResult)
+ {
+ requestPacketResult = RequestPacketReturn(aResponse);
+ }
+
+ // Provide function result to caller
+ return requestPacketResult;
+ }
+
+TBool CObexServerPacketAccessUi::RequestPacket(TObexRequestCode aRequest, CObex::TSetPathInfo& aSetPathInfo, TObexResponse& aResponse)
+ {
+ TBool requestPacketResult(ETrue);
+
+ iConsole->Printf(_L("Request code %d - SetPath\r\n"), aRequest);
+ iConsole->Printf(_L("\tParent=%d\r\n"), aSetPathInfo.Parent());
+ iConsole->Printf(_L("\tSetPath flags=0x%02x, constants=0x%02x\r\n"), aSetPathInfo.iFlags, aSetPathInfo.iConstants);
+ if (aSetPathInfo.iNamePresent)
+ {
+ iConsole->Printf(_L("\tDestination directory=%S\r\n"), &(aSetPathInfo.iName));
+ }
+
+ // Use Packet Headers now
+ CObexHeaderSet* headerSet = NULL;
+ iServer.PacketHeaders(headerSet);
+ if (headerSet)
+ {
+ // Ensures that if the function leaves then the only option is to
+ // report a false operation. As RequestPacket function signiture is published partner
+ TRAPD(err,PrintHeadersL(*headerSet));
+ if (err != KErrNone)
+ {
+ requestPacketResult = EFalse;
+ }
+ delete headerSet;
+ }
+
+ if (requestPacketResult)
+ {
+ requestPacketResult = RequestPacketReturn(aResponse);
+ }
+
+ // Provide function result to caller
+ return requestPacketResult;
+ }
+
+TBool CObexServerPacketAccessUi::RequestPacketReturn(TObexResponse& aResponse)
+ {
+ if (iInteractive)
+ {
+ TKeyCode key(EKeyNull);
+ TBuf<2> buf;
+ aResponse = ERespBadRequest;
+
+ Cancel(); // cancel getting key presses will in "submenu"
+
+ iConsole->Printf(_L("Adandon Packet? (y/n) "));
+ while (key != 'y' && key != 'Y' && key != 'n' && key != 'N')
+ {
+ key = iConsole->Getch();
+ }
+ iConsole->Printf(_L("%c"),key);
+ if (key == 'n' || key == 'N')
+ {
+ SetKeypressActive(); // reactivate key handling
+ iConsole->Printf(_L("\r\n"));
+ return ETrue;
+ }
+
+ // If here then we are abandoning the packet
+ iConsole->Printf(_L("\r\nResponse to send? 0x"));
+
+ while ((key = iConsole->Getch()) != EKeyEnter)
+ {
+ if (key == EKeyBackspace && buf.Length()!=0)
+ {
+ buf.SetLength(buf.Length()-1);
+ }
+ else if( buf.Length() < buf.MaxLength())
+ {
+ buf.Append(key);
+ }
+ else
+ continue;
+ iConsole->Printf(_L("%c"),key);
+ }
+ iConsole->Printf(_L("\r\n"));
+
+ TLex lex(buf);
+ TUint value;
+ TInt lex_err = lex.Val(value, EHex);
+
+ if(lex_err == KErrNone)
+ {
+ aResponse = static_cast<TObexResponse>(value);
+ }
+ else
+ {
+ iConsole->Printf(_L("Input parsing failed, use ERespBadRequest as default response\r\n"));
+ }
+ SetKeypressActive(); // reactivate key handling
+ return EFalse;
+ }
+ else
+ {
+ return ETrue;
+ }
+ }
+
+CConsoleBase& CObexServerPacketAccessUi::Console() const
+ {
+ return *iConsole;
+ }
+
+void CObexServerPacketAccessUi::PrintHeadersL(CObexHeaderSet& aHeaderSet) const
+ {
+ CObexHeader* header = CObexHeader::NewL();
+ CleanupStack::PushL(header);
+
+ aHeaderSet.First();
+ TInt err(aHeaderSet.This(header));
+ if (err == KErrNone)
+ {
+ iConsole->Printf(_L("Packet header contents...\r\n"));
+ }
+ while (err == KErrNone)
+ {
+ // get the next header
+ err = aHeaderSet.This(header);
+ if (err != KErrNone)
+ {
+ break;
+ }
+
+ PrintHeader(*header);
+
+ err = aHeaderSet.Next();
+ }
+
+ CleanupStack::PopAndDestroy(header);
+ }
+
+void CObexServerPacketAccessUi::PrintHeader(CObexHeader& aHeader) const
+ {
+ // appropriately print the header
+ iConsole->Printf(_L("\tHI: %d\r\n"),aHeader.HI());
+
+ CObexHeader::THeaderType type = aHeader.Type();
+ switch(type)
+ {
+ case CObexHeader::EUnicode:
+ {
+ const TDesC16& headerdes = aHeader.AsUnicode();
+ const TUint8* bytes = reinterpret_cast<const TUint8*>(headerdes.Ptr());
+ PrintHex(bytes, headerdes.Size());
+ }
+ break;
+ case CObexHeader::EByteSeq:
+ {
+ const TDesC8& headerbyteseq = aHeader.AsByteSeq();
+ PrintHex(headerbyteseq.Ptr(), headerbyteseq.Size());
+ }
+ break;
+ case CObexHeader::EByte:
+ {
+ const TUint8 headerbyte = aHeader.AsByte();
+ PrintHex(&headerbyte, 1);
+ }
+ break;
+ case CObexHeader::EFourByte:
+ {
+ const TUint32 headerbytes = aHeader.AsFourByte();
+ const TUint8* bytes = reinterpret_cast<const TUint8*>(&headerbytes);
+ PrintHex(bytes, 4);
+ }
+ break;
+ default:
+ // panic here maybe??
+ break;
+ }
+ }
+
+void CObexServerPacketAccessUi::PrintHex(const TUint8* aPtr, TInt aLength) const
+ {
+ // local constants
+ const TUint32 widthC = 8;
+ _LIT(KPrintHexByte, "%02x ");
+ _LIT(KPrintHexTab, "\t");
+ _LIT(KPrintHexChar, "%c ");
+ _LIT(KPrintHexNonchar, ". ");
+ _LIT(KPrintHexNewline, "\r\n");
+ _LIT(KPrintHex2Spaces, " ");
+ _LIT(KPrintHex3Spaces, " ");
+
+ // function begins...
+ TInt length = 0;
+ TUint32 cursor = 0;
+
+ TUint8 printArray[widthC];
+
+ while (length < aLength)
+ {
+ printArray[cursor] = *aPtr;
+
+ // move along.
+ aPtr++;
+ length++;
+ cursor = length % widthC;
+
+ if (cursor == 0)
+ {
+ // we have a full array so print it.
+ iConsole->Printf(KPrintHexTab());
+ for (TUint i=0;i<widthC;i++)
+ {
+ iConsole->Printf(KPrintHexByte(),printArray[i]);
+ }
+ iConsole->Printf(KPrintHexTab());
+ for (TUint i=0;i<widthC;i++)
+ {
+ TUint8 c = printArray[i];
+ if (c >= 32 && c <= 126)
+ {
+ iConsole->Printf(KPrintHexChar(), c);
+ }
+ else
+ {
+ iConsole->Printf(KPrintHexNonchar());
+ }
+ }
+ iConsole->Printf(KPrintHexNewline());
+ }
+ }
+
+ // if we haven't completely finished a set -> finish it
+ if (cursor > 0)
+ {
+ iConsole->Printf(KPrintHexTab());
+ for (TUint i=0;i<widthC;i++)
+ {
+ if (i >= cursor)
+ {
+ iConsole->Printf(KPrintHex3Spaces());
+ }
+ else
+ {
+ iConsole->Printf(KPrintHexByte(),printArray[i]);
+ }
+ }
+ iConsole->Printf(KPrintHexTab());
+ for (TUint i=0;i<widthC;i++)
+ {
+ if (i >= cursor)
+ {
+ iConsole->Printf(KPrintHex2Spaces());
+ }
+ else
+ {
+ TUint8 c = printArray[i];
+ if (c >= 32 && c <= 126)
+ {
+ iConsole->Printf(KPrintHexChar(), c);
+ }
+ else
+ {
+ iConsole->Printf(KPrintHexNonchar());
+ }
+ }
+ }
+ iConsole->Printf(KPrintHexNewline());
+ }
+
+ // should be printed now
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obex/test/tobex/serverpacketaccessui.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,72 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef _SERVERPACKETACCESSUI_H
+#define _SERVERPACKETACCESSUI_H
+
+#include <e32base.h>
+#include <obex/extensionapis/mobexserverrequestpacketnotify.h>
+
+
+class CObexServerHandlerBase;
+class CConsoleBase;
+class CObexServerPacketAccessExtension;
+class CObexServer;
+
+
+NONSHARABLE_CLASS(CObexServerPacketAccessUi) : public CActive, MObexServerRequestPacketNotify
+ {
+
+public:
+ static CObexServerPacketAccessUi* NewL(CObexServerHandlerBase& aHandler, CObexServer& aServer);
+ ~CObexServerPacketAccessUi();
+
+ void SetKeypressActive();
+ CConsoleBase& Console() const;
+
+private:
+ // MObexServerRequestPacketNotify
+ virtual TBool RequestPacket(TObexRequestCode aRequest, TObexResponse& aResponse);
+ virtual TBool RequestPacket(TObexRequestCode aRequest, TObexConnectInfo& aConnectInfo, TObexResponse& aResponse);
+ virtual TBool RequestPacket(TObexRequestCode aRequest, CObex::TSetPathInfo& aSetPathInfo, TObexResponse& aResponse);
+
+private:
+ CObexServerPacketAccessUi(CObexServerHandlerBase& aHandler, CObexServer& aServer);
+ void ConstructL();
+
+ void RunL();
+ void DoCancel();
+
+ void ProcessKeyPressL(TChar aChar);
+
+ void PrintHeadersL(CObexHeaderSet& aHeaderSet) const;
+ void PrintHeader(CObexHeader& aHeader) const;
+ void PrintHex(const TUint8* aPtr, TInt aLength) const;
+
+ TBool RequestPacketReturn(TObexResponse& aResponse);
+
+private:
+ CObexServerHandlerBase& iHandler;
+ CObexServer& iServer;
+
+ CConsoleBase* iConsole;
+ CObexServerPacketAccessExtension* iPacketAccess;
+
+ TBool iInteractive;
+
+ };
+
+
+#endif // _SERVERPACKETACCESSUI_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/group/ObexBtRfcommTransportController.mmp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,56 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// ObexBtRfcommTransportController.dll Part of the Obex BT RFCOMM
+// Controller plugin, used to control the RFCOMM transport.
+// ObexBtRfcommTransportController.rsc Part of the Obex BT RFCOMM
+// Controller plugin, used to control the RFCOMM transport.
+//
+//
+
+/**
+ @file
+*/
+
+TARGET obexbtrfcommtransportcontroller.dll //Recommended unpaged
+TARGETTYPE PLUGIN
+// UID2 = 0x10009d8d for ECOM plugins.
+// UID3 = the 'DLL UID' (see resource file)
+UID 0x10009d8d 0x1020E043
+VENDORID 0x70000001
+CAPABILITY All -Tcb
+
+SOURCEPATH ../src
+SOURCE ObexBtRfcommImpCollection.cpp
+SOURCE ObexBtRfcommTransportController.cpp
+SOURCE ObexActiveRfcommConnector.cpp
+SOURCE ObexListenerRfcommConnector.cpp
+SOURCE ObexRfcommConnector.cpp
+
+START RESOURCE 1020E043.rss
+target obexbtrfcommtransportcontroller.rsc
+END
+
+USERINCLUDE ../inc
+USERINCLUDE ../../common
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY euser.lib
+LIBRARY obexcommontransport.lib
+LIBRARY esock.lib
+LIBRARY bluetooth.lib
+
+NOEXPORTLIBRARY
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/group/bld.inf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,17 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_MMPFILES
+ObexBtRfcommTransportController.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/ObexActiveRfcommConnector.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,53 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXACTIVERFCOMMCONNECTOR_H
+#define OBEXACTIVERFCOMMCONNECTOR_H
+
+#include <e32base.h>
+#include <bt_sock.h>
+
+class MConnectObserver;
+
+/**
+Simple active object to call Connect on a socket. Only one Connect operation
+may be outstanding at any time.
+*/
+NONSHARABLE_CLASS(CObexActiveRfcommConnector) : public CActive
+ {
+public:
+ CObexActiveRfcommConnector(MConnectObserver& aParent,
+ RSocketServ& aSocketServ,
+ RSocket& aSocket,
+ const TProtocolDesc& aProtocolDesc,
+ const TBTSockAddr& aAddr);
+ ~CObexActiveRfcommConnector();
+
+public:
+ void ConnectL();
+
+private: // from CActive
+ void RunL();
+ void DoCancel();
+
+private: // unowned
+ MConnectObserver& iParent;
+ RSocketServ& iSocketServ;
+ RSocket& iSocket;
+ const TProtocolDesc& iProtocolDesc;
+ const TBTSockAddr& iAddr;
+ };
+
+#endif // OBEXACTIVERFCOMMCONNECTOR_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/ObexBtRfcommTransportController.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,45 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXBTRFCOMMTRANSPORTCONTROLLER_H__
+#define __OBEXBTRFCOMMTRANSPORTCONTROLLER_H__
+
+#include <obex/transport/obextransportcontrollerbase.h>
+
+/**
+@internalComponent
+Transport Controller for the transport BT RFCOMM
+*/
+NONSHARABLE_CLASS(CObexBtRfcommTransportController) : public CObexTransportControllerBase
+ {
+public:
+ static CObexBtRfcommTransportController* NewL(TObexTransportInfo& aTransportInfo);
+ ~CObexBtRfcommTransportController();
+
+private: // from CObexTransportControllerBase
+ void DoRemoteAddr(TSockAddr& aAddr);
+ void NewTransportL(TObexConnectionInfo& aInfo);
+ TBool DoIsTransportRestartable() const;
+ TUint16 GetReceivePacketDataLimit();
+ void DoProcess(CObexPacket& aPacket);
+ void DoError(TInt aError);
+ void DoTransportUp(TObexConnectionInfo& aInfo);
+
+private:
+ CObexBtRfcommTransportController();
+ void ConstructL(TObexTransportInfo& aTransportInfo);
+ };
+
+#endif // __OBEXBTRFCOMMTRANSPORTCONTROLLER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/ObexListenerRfcommConnector.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,56 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXLISTENERRFCOMMCONNECTOR_H
+#define OBEXLISTENERRFCOMMCONNECTOR_H
+
+#include <e32base.h>
+#include <bt_sock.h>
+
+class MConnectObserver;
+
+/**
+Simple Active Object to call Accept for a socket. Only one accept operation
+may be outstanding at any time. It has its own listening socket.
+*/
+NONSHARABLE_CLASS(CObexListenerRfcommConnector) : public CActive
+ {
+public:
+ CObexListenerRfcommConnector(MConnectObserver& aParent,
+ RSocketServ& aSocketServ,
+ RSocket& aSocket,
+ const TProtocolDesc& aProtocolDesc,
+ TBTSockAddr& aAddr);
+ ~CObexListenerRfcommConnector();
+
+public:
+ void AcceptL();
+
+private: // from CActive
+ void RunL();
+ void DoCancel();
+
+private: // unowned
+ MConnectObserver& iParent;
+ RSocketServ& iSocketServ;
+ RSocket& iSocket;
+ const TProtocolDesc& iProtocolDesc;
+ TBTSockAddr& iAddr;
+
+private: // owned
+ RSocket iListeningSocket;
+ };
+
+#endif // OBEXLISTENERRFCOMMCONNECTOR_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/ObexRfcommConnector.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,65 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef OBEXRFCOMMCONNECTOR_H
+#define OBEXRFCOMMCONNECTOR_H
+
+#include <bt_sock.h>
+#include <obex/transport/obexconnector.h>
+#include "connectobserver.h"
+
+class CObexActiveRfcommConnector;
+class CObexListenerRfcommConnector;
+class MObexTransportNotify;
+class TObexBtTransportInfo;
+
+NONSHARABLE_CLASS(CObexRfcommConnector) : public CObexConnector,
+ public MConnectObserver
+ {
+public:
+ static CObexRfcommConnector* NewL(MObexTransportNotify& aOwner,
+ TBTSockAddr& aAddr);
+ ~CObexRfcommConnector();
+
+public:
+ RSocket& GetSocket();
+
+private:
+ CObexRfcommConnector(MObexTransportNotify& aOwner,
+ TBTSockAddr& aAddr);
+ void ConstructL();
+
+private: // from CObexConnector
+ void ConnectL();
+ void CancelConnect();
+ void AcceptL();
+ void CancelAccept();
+ TBool BringTransportDown();
+ void SignalTransportError();
+
+private: // from MConnectObserver
+ void ConnectComplete(TInt aError, TObexConnectionInfo& aSockinfo);
+
+private: // owned
+ CObexActiveRfcommConnector* iConnector;
+ CObexListenerRfcommConnector* iReceiver;
+ TBool iTransportUp;
+ RSocket iSocket;
+ RSocketServ iSocketServ;
+ TBTSockAddr& iAddr;
+ TProtocolDesc iProtocolDesc;
+ };
+
+#endif // OBEXRFCOMMCONNECTOR_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/connectobserver.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,37 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Interface for notification of the completion of a connect request.
+//
+//
+
+/**
+ @file
+*/
+
+#ifndef CONNECTOBSERVER_H
+#define CONNECTOBSERVER_H
+
+#include <e32base.h>
+
+class TObexConnectionInfo;
+
+class MConnectObserver
+ {
+public:
+ /** A connect request has completed with the given error. If this is
+ KErrNone, aSockinfo will hold connection information. */
+ virtual void ConnectComplete(TInt aError, TObexConnectionInfo& aSockinfo) = 0;
+ };
+
+#endif // CONNECTOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/inc/obexbtfaults.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,34 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXBTFAULTS_H
+#define __OBEXBTFAULTS_H
+
+/**
+@file
+
+This file contains bt specific panics internal to obex
+@internalComponent
+*/
+
+enum TObexBtFaultCode
+ {
+ EActiveRfcommConnInternalError = 0,
+ EListRfcommInternalError = 1,
+ ERfcommConnectorInternalError = 2,
+ ERfcommTcInternalError = 3,
+ };
+
+#endif // __OBEXBTFAULTS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/1020E043.rss Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,40 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/registryinfo.rh>
+#include <obex/transport/obextransport.hrh>
+
+RESOURCE REGISTRY_INFO theInfo
+ {
+ dll_uid = 0x1020E043;
+ interfaces =
+ {
+ INTERFACE_INFO
+ {
+ interface_uid = KObexTransportInterfaceUid;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x1020E044;
+ version_no = 1;
+ display_name = "ObexBtRfcomm";
+ default_data = "RFCOMM";
+ opaque_data = "";
+ }
+ };
+ }
+ };
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexActiveRfcommConnector.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,109 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexconnector.h>
+#include "ObexActiveRfcommConnector.h"
+#include "connectobserver.h"
+#include "logger.h"
+#include "obexbtfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "RFCOMM");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ActiveRfcommConn");
+#endif
+
+CObexActiveRfcommConnector::CObexActiveRfcommConnector(MConnectObserver& aParent,
+ RSocketServ& aSocketServ,
+ RSocket& aSocket,
+ const TProtocolDesc& aProtocolDesc,
+ const TBTSockAddr& aAddr)
+ : CActive(EPriorityStandard),
+ iParent(aParent),
+ iSocketServ(aSocketServ),
+ iSocket(aSocket),
+ iProtocolDesc(aProtocolDesc),
+ iAddr(aAddr)
+ {
+ LOG_FUNC
+ LOG(_L8("\taAddr:"));
+ LOGHEXDESC(aAddr);
+
+ CActiveScheduler::Add(this);
+ }
+
+CObexActiveRfcommConnector::~CObexActiveRfcommConnector()
+ {
+ LOG_FUNC
+
+ Cancel();
+ }
+
+void CObexActiveRfcommConnector::RunL()
+ {
+ LOG_LINE
+ LOG_FUNC
+ LOG1(_L8("\tiStatus = %d"), iStatus.Int());
+
+ // This exists purely as a sanity-check on our internal state.
+ __ASSERT_DEBUG(iSocket.SubSessionHandle(), PANIC(KPanicCat, EActiveRfcommConnInternalError));
+
+ TObexConnectionInfo sockinfo;
+ if ( iStatus == KErrNone )
+ {
+ sockinfo.iSocketType = TObexConnectionInfo::ESocketStream;
+
+ TPckgBuf<TUint> optBuf(65535); //If all else fails we should get a max 64K buffer
+ iSocket.GetOpt(KRFCOMMMaximumMTU, KSolBtRFCOMM, optBuf);
+
+ // Set socket buffer sizes based on negotiated MTU
+ iSocket.SetOpt(KSOSendBuf, KSOLSocket, optBuf);
+ iSocket.SetOpt(KSORecvBuf, KSOLSocket, optBuf);
+ }
+ else
+ {
+ iSocket.Close();
+ }
+
+ iParent.ConnectComplete(iStatus.Int(), sockinfo);
+ }
+
+void CObexActiveRfcommConnector::DoCancel()
+ {
+ LOG_FUNC
+
+ // This exists purely as a sanity-check on our internal state.
+ __ASSERT_DEBUG(iSocket.SubSessionHandle(), PANIC(KPanicCat, EActiveRfcommConnInternalError));
+ iSocket.CancelConnect();
+ iSocket.Close();
+ }
+
+void CObexActiveRfcommConnector::ConnectL()
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(!iSocket.SubSessionHandle(), PANIC(KPanicCat, EActiveRfcommConnInternalError));
+ LEAVEIFERRORL(iSocket.Open(iSocketServ,
+ iProtocolDesc.iAddrFamily,
+ iProtocolDesc.iSockType,
+ iProtocolDesc.iProtocol));
+
+ // iAddr is logically const, and needs constness casting away for this
+ // API.
+ iSocket.Connect(const_cast<TBTSockAddr&>(iAddr), iStatus);
+ SetActive();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexBtRfcommImpCollection.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,30 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "ObexBtRfcommTransportController.h"
+
+const TImplementationProxy ObexTCImplementationTable[] =
+ {
+ IMPLEMENTATION_PROXY_ENTRY(0x1020E044, CObexBtRfcommTransportController::NewL),
+ };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+ {
+ aTableCount = sizeof(ObexTCImplementationTable) / sizeof(TImplementationProxy);
+
+ return ObexTCImplementationTable;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexBtRfcommTransportController.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,163 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obexbttransportinfo.h>
+#include <obex/transport/obexactivereader.h>
+#include <obex/transport/obexactivewriter.h>
+#include "ObexBtRfcommTransportController.h"
+#include "ObexRfcommConnector.h"
+#include "logger.h"
+#include "obexbtfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "RFCOMM");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "BtRfcommTc");
+#endif
+
+/**
+Constructs a CObexBtRfcommTransportController object.
+@return Ownership of a new CObexIrdaTtpTransportController object.
+*/
+CObexBtRfcommTransportController* CObexBtRfcommTransportController::NewL(TObexTransportInfo& aTransportInfo)
+ {
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexBtRfcommTransportController* self = new(ELeave) CObexBtRfcommTransportController;
+ CleanupStack::PushL(self);
+ self->ConstructL(aTransportInfo);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/** Constructor.
+*/
+CObexBtRfcommTransportController::CObexBtRfcommTransportController()
+ :CObexTransportControllerBase()
+ {
+ LOG_FUNC
+ }
+
+/** 2nd phase construction.
+*/
+void CObexBtRfcommTransportController::ConstructL(TObexTransportInfo& aTransportInfo)
+ {
+ LOG_FUNC
+
+ // It's important in the current implementation to do these these in
+ // roughly this order. We pass the address part of the base class's
+ // transport info by reference to the connector and thence to the
+ // listener. If the user has specified RFCOMM 'passive auto bind' then
+ // just updating the address in the listener will update the transport
+ // controller base's transport info for later query by the user. Using
+ // references saves having to add functions to achieve a manual update of
+ // the data.
+ iTransportInfo = new(ELeave) TObexBtTransportInfo;
+ Mem::Copy(iTransportInfo, &aTransportInfo, sizeof(TObexBtTransportInfo));
+ TObexBtTransportInfo* btTransportInfo = static_cast<TObexBtTransportInfo*>(iTransportInfo);
+ iConnector = CObexRfcommConnector::NewL(*this, btTransportInfo->iAddr);
+ }
+
+/** Destructor.
+*/
+CObexBtRfcommTransportController::~CObexBtRfcommTransportController()
+ {
+ LOG_FUNC
+ }
+
+/**
+Gets the socket associated with the connector and asks the socket for its remote name.
+This can be cast to the appropriate TSockAddr-derived class (TBTSockAddr for BT).
+*/
+void CObexBtRfcommTransportController::DoRemoteAddr(TSockAddr& aAddr)
+ {
+ LOG_FUNC
+ LOG(_L8("\taAddr:"));
+ LOGHEXDESC(aAddr);
+
+ __ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommTcInternalError));
+ RSocket& socket = static_cast<CObexRfcommConnector*>(iConnector)->GetSocket();
+ socket.RemoteName(aAddr);
+ }
+
+TBool CObexBtRfcommTransportController::DoIsTransportRestartable() const
+ {
+ LOG_FUNC
+
+ return ETrue;
+ }
+
+TUint16 CObexBtRfcommTransportController::GetReceivePacketDataLimit()
+ {
+ LOG_FUNC
+
+ // Set initial "software throttle" for packets (how big OBEX says they are)
+ __ASSERT_DEBUG(iTransportInfo, PANIC(KPanicCat, ERfcommTcInternalError));
+ TUint16 receivePacketDataLimit = iTransportInfo->iReceiveMtu;
+ return receivePacketDataLimit;
+ }
+
+/**
+Creates the reader and writer and constructs the packets
+@param aInfo Connection info to pass to active reader/writer classes
+*/
+void CObexBtRfcommTransportController::NewTransportL(TObexConnectionInfo& aInfo)
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommTcInternalError));
+ RSocket& socket = static_cast<CObexRfcommConnector*>(iConnector)->GetSocket();
+ iActiveReader = CObexActiveReader::NewL(*this, socket, aInfo);
+ iActiveWriter = CObexActiveWriter::NewL(*this, socket, aInfo);
+ }
+
+//From MObexTransportNotify
+/**
+Process the received packet
+@param aPacket Packet to process
+*/
+void CObexBtRfcommTransportController::DoProcess(CObexPacket &aPacket)
+ {
+ LOG_FUNC
+
+ CObexTransportControllerBase::DoProcess(aPacket);
+ }
+
+/**
+Calls base implementation
+Future proofing against BC breaks
+@param aError Error code
+*/
+void CObexBtRfcommTransportController::DoError(TInt aError)
+ {
+ LOG_FUNC
+ LOG1(_L8("\taError = %d"), aError);
+
+ CObexTransportControllerBase::DoError(aError);
+ }
+
+/**
+Calls base implementation
+Future proofing against BC breaks
+@param aInfo Connection info to pass to active reader/writer classes
+*/
+void CObexBtRfcommTransportController::DoTransportUp(TObexConnectionInfo& aInfo)
+ {
+ LOG_FUNC
+
+ CObexTransportControllerBase::DoTransportUp(aInfo);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexListenerRfcommConnector.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,138 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexconnector.h>
+#include "ObexListenerRfcommConnector.h"
+#include "connectobserver.h"
+#include "logger.h"
+#include "obexbtfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "RFCOMM");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ListRfcomm");
+#endif
+
+CObexListenerRfcommConnector::CObexListenerRfcommConnector(MConnectObserver& aParent,
+ RSocketServ& aSocketServ,
+ RSocket& aSocket,
+ const TProtocolDesc& aProtocolDesc,
+ TBTSockAddr& aAddr)
+ : CActive(EPriorityStandard),
+ iParent(aParent),
+ iSocketServ(aSocketServ),
+ iSocket(aSocket),
+ iProtocolDesc(aProtocolDesc),
+ iAddr(aAddr)
+ {
+ LOG_FUNC
+ LOG(_L8("\taAddr:"));
+ LOGHEXDESC(aAddr);
+
+ CActiveScheduler::Add(this);
+ }
+
+CObexListenerRfcommConnector::~CObexListenerRfcommConnector()
+ {
+ LOG_FUNC
+
+ Cancel();
+
+ // iListeningSocket will only have been open if there was a request
+ // outstanding, in which case it will have been closed in DoCancel, so no
+ // need to do it here.
+ __ASSERT_DEBUG(!iListeningSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+ }
+
+void CObexListenerRfcommConnector::RunL()
+ {
+ LOG_LINE
+ LOG_FUNC
+ LOG1(_L8("\tiStatus = %d"), iStatus.Int());
+
+ // These exists purely as sanity-checks on our internal state.
+ __ASSERT_DEBUG(iSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+ __ASSERT_DEBUG(iListeningSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+
+ TObexConnectionInfo sockinfo;
+ if ( iStatus == KErrNone )
+ {
+ sockinfo.iSocketType = TObexConnectionInfo::ESocketStream;
+
+ TPckgBuf<TUint> optBuf(65535); //If all else fails we should get a max 64K buffer
+ iSocket.GetOpt(KRFCOMMMaximumMTU, KSolBtRFCOMM, optBuf);
+
+ // Set socket buffer sizes based on negotiated MTU
+ iSocket.SetOpt(KSOSendBuf, KSOLSocket, optBuf);
+ iSocket.SetOpt(KSORecvBuf, KSOLSocket, optBuf);
+ }
+ else
+ {
+ iSocket.Close();
+ }
+
+ iListeningSocket.Close();
+ iParent.ConnectComplete(iStatus.Int(), sockinfo);
+ }
+
+void CObexListenerRfcommConnector::DoCancel()
+ {
+ LOG_FUNC
+
+ // These exist purely as sanity-checks on our internal state.
+ __ASSERT_DEBUG(iSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+ __ASSERT_DEBUG(iListeningSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+ iListeningSocket.CancelAccept();
+ iListeningSocket.Close();
+ iSocket.Close();
+ }
+
+void CObexListenerRfcommConnector::AcceptL()
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(!iSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+
+ __ASSERT_DEBUG(!iListeningSocket.SubSessionHandle(), PANIC(KPanicCat, EListRfcommInternalError));
+ LEAVEIFERRORL(iListeningSocket.Open(iSocketServ,
+ iProtocolDesc.iAddrFamily,
+ iProtocolDesc.iSockType,
+ iProtocolDesc.iProtocol));
+ CleanupClosePushL(iListeningSocket);
+
+ LEAVEIFERRORL(iListeningSocket.Bind(iAddr));
+ if ( iAddr.Port() == KRfcommPassiveAutoBind )
+ {
+ const TUint port = iListeningSocket.LocalPort();
+ LOG1(_L8("\tKRfcommPassiveAutoBind was specified- really using port %d"), port);
+ // This updates the concrete transport controller's iTransportInfo member (by reference).
+ iAddr.SetPort(port);
+ }
+ // We try to set the Object Transfer bit in our service class. If this fails we
+ // ignore it, as it's better to carry on without it than to fail to start listening.
+ (void)iListeningSocket.SetOpt(KBTRegisterCodService, KSolBtRFCOMM, EMajorServiceObjectTransfer);
+ LEAVEIFERRORL(iListeningSocket.Listen(4)); // queue size of 4
+
+ // NB Client does SDP & Sec registration.
+
+ LEAVEIFERRORL(iSocket.Open(iSocketServ));
+
+ CleanupStack::Pop(&iListeningSocket);
+
+ iListeningSocket.Accept(iSocket, iStatus);
+ SetActive();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexbttransport/src/ObexRfcommConnector.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,176 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/mobextransportnotify.h>
+#include <obexbttransportinfo.h>
+#include "ObexRfcommConnector.h"
+#include "ObexActiveRfcommConnector.h"
+#include "ObexListenerRfcommConnector.h"
+#include "logger.h"
+#include "obexbtfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "RFCOMM");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "RfcommConnector");
+#endif
+
+CObexRfcommConnector* CObexRfcommConnector::NewL(MObexTransportNotify& aOwner,
+ TBTSockAddr& aAddr)
+ {
+ LOG_STATIC_FUNC_ENTRY
+
+ CObexRfcommConnector* self = new(ELeave) CObexRfcommConnector(aOwner, aAddr);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CObexRfcommConnector::CObexRfcommConnector(MObexTransportNotify& aObserver,
+ TBTSockAddr& aAddr)
+ : CObexConnector(aObserver),
+ iAddr(aAddr)
+ {
+ LOG_FUNC
+ LOG(_L8("\taAddr:"));
+ LOGHEXDESC(aAddr);
+ }
+
+void CObexRfcommConnector::ConstructL()
+ {
+ LOG_FUNC
+
+ LEAVEIFERRORL(iSocketServ.Connect());
+ LEAVEIFERRORL(iSocketServ.FindProtocol(_L("RFCOMM"), iProtocolDesc));
+
+ iConnector = new(ELeave) CObexActiveRfcommConnector(*this, iSocketServ, iSocket, iProtocolDesc, iAddr);
+ iReceiver = new(ELeave) CObexListenerRfcommConnector(*this, iSocketServ, iSocket, iProtocolDesc, iAddr);
+
+ BaseConstructL();
+ }
+
+CObexRfcommConnector::~CObexRfcommConnector()
+ {
+ LOG_FUNC
+
+ delete iConnector;
+ delete iReceiver;
+ iSocket.Close();
+ iSocketServ.Close();
+ }
+
+void CObexRfcommConnector::ConnectL()
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommConnectorInternalError));
+ iConnector->ConnectL();
+ }
+
+void CObexRfcommConnector::CancelConnect()
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommConnectorInternalError));
+ iConnector->Cancel();
+ }
+
+void CObexRfcommConnector::AcceptL()
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iReceiver, PANIC(KPanicCat, ERfcommConnectorInternalError));
+ iReceiver->AcceptL();
+ }
+
+void CObexRfcommConnector::CancelAccept()
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iReceiver, PANIC(KPanicCat, ERfcommConnectorInternalError));
+ iReceiver->Cancel();
+ }
+
+TBool CObexRfcommConnector::BringTransportDown()
+ {
+ LOG_FUNC
+
+ // There's a nasty contract going on here- at most, only one of these AOs
+ // should be active at any time. They each use this object's iSocket,
+ // opening and closing it, and asserting its SubSessionHandle at various
+ // points. They may be better designed as a single AO state machine.
+ __ASSERT_DEBUG(iConnector, PANIC(KPanicCat, ERfcommConnectorInternalError));
+ iConnector->Cancel();
+ __ASSERT_DEBUG(iReceiver, PANIC(KPanicCat, ERfcommConnectorInternalError));
+ iReceiver->Cancel();
+
+ // For cases where the underlying transport has gone we'll
+ // do an Immediate Shutdown to prevent Close() from blocking.
+ // This should stop dialogs from "freezing".
+ //returns true as this transport proceeds with taking down the transport
+ if ( iTransportUp )
+ {
+ TRequestStatus status;
+ iSocket.Shutdown(RSocket::EImmediate, status);
+ User::WaitForRequest(status);
+ iTransportUp = EFalse;
+ }
+
+ iSocket.Close();
+ return ETrue;
+ }
+
+/** Used to set any link layer specific error condition flags. Bluetooth has
+none, so the function is a stub. */
+void CObexRfcommConnector::SignalTransportError()
+ {
+ LOG_FUNC
+ }
+
+/**
+Returns the socket instance iSocket
+@return RSocket
+*/
+RSocket& CObexRfcommConnector::GetSocket()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iSocket;
+ }
+
+/**
+This method is used to field completed connections from both the active
+connector and the listen/acceptor.
+*/
+void CObexRfcommConnector::ConnectComplete(TInt aError, TObexConnectionInfo& aSockinfo)
+ {
+ LOG_FUNC
+ LOG1(_L8("\taError = %d"), aError);
+
+ if ( aError == KErrNone )
+ {
+ Observer().TransportUp(aSockinfo);
+ iTransportUp = ETrue;
+ }
+ else
+ {
+ Observer().Error(aError);
+ __ASSERT_DEBUG(!iTransportUp, PANIC(KPanicCat, ERfcommConnectorInternalError));
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/bwins/obexcommontransportU.def Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,110 @@
+EXPORTS
+ ??0CObexConnector@@QAE@AAVMObexTransportNotify@@@Z @ 1 NONAME ; CObexConnector::CObexConnector(class MObexTransportNotify &)
+ ??0CObexReaderBase@@IAE@W4TPriority@CActive@@AAVMObexTransportNotify@@AAUTObexConnectionInfo@@@Z @ 2 NONAME ; CObexReaderBase::CObexReaderBase(enum CActive::TPriority, class MObexTransportNotify &, struct TObexConnectionInfo &)
+ ??0CObexTransportControllerBase@@IAE@XZ @ 3 NONAME ; CObexTransportControllerBase::CObexTransportControllerBase(void)
+ ??0CObexWriterBase@@IAE@W4TPriority@CActive@@AAVMObexTransportNotify@@AAUTObexConnectionInfo@@@Z @ 4 NONAME ; CObexWriterBase::CObexWriterBase(enum CActive::TPriority, class MObexTransportNotify &, struct TObexConnectionInfo &)
+ ??0TFunctionLogger@@QAE@ABVTDesC8@@0PAX@Z @ 5 NONAME ; TFunctionLogger::TFunctionLogger(class TDesC8 const &, class TDesC8 const &, void *)
+ ??0TObexInternalHeader@@QAE@XZ @ 6 NONAME ; TObexInternalHeader::TObexInternalHeader(void)
+ ??1CObexActiveReader@@UAE@XZ @ 7 NONAME ; CObexActiveReader::~CObexActiveReader(void)
+ ??1CObexActiveWriter@@UAE@XZ @ 8 NONAME ; CObexActiveWriter::~CObexActiveWriter(void)
+ ??1CObexConnector@@UAE@XZ @ 9 NONAME ; CObexConnector::~CObexConnector(void)
+ ??1CObexPacket@@UAE@XZ @ 10 NONAME ; CObexPacket::~CObexPacket(void)
+ ??1CObexReaderBase@@UAE@XZ @ 11 NONAME ; CObexReaderBase::~CObexReaderBase(void)
+ ??1CObexTransportControllerBase@@UAE@XZ @ 12 NONAME ; CObexTransportControllerBase::~CObexTransportControllerBase(void)
+ ??1CObexWriterBase@@UAE@XZ @ 13 NONAME ; CObexWriterBase::~CObexWriterBase(void)
+ ??1TFunctionLogger@@QAE@XZ @ 14 NONAME ; TFunctionLogger::~TFunctionLogger(void)
+ ?AcceptConnectionL@CObexTransportControllerBase@@QAEXXZ @ 15 NONAME ; void CObexTransportControllerBase::AcceptConnectionL(void)
+ ?AddPacketProcessEvents@CObexPacket@@QAEXI@Z @ 16 NONAME ; void CObexPacket::AddPacketProcessEvents(unsigned int)
+ ?BaseConstructL@CObexConnector@@IAEXXZ @ 17 NONAME ; void CObexConnector::BaseConstructL(void)
+ ?BaseConstructL@CObexReaderBase@@IAEXXZ @ 18 NONAME ; void CObexReaderBase::BaseConstructL(void)
+ ?BaseConstructL@CObexWriterBase@@IAEXXZ @ 19 NONAME ; void CObexWriterBase::BaseConstructL(void)
+ ?BringTransportDown@CObexTransportControllerBase@@QAEHXZ @ 20 NONAME ; int CObexTransportControllerBase::BringTransportDown(void)
+ ?BufferSize@CObexPacket@@QBEGXZ @ 21 NONAME ; unsigned short CObexPacket::BufferSize(void) const
+ ?CancelAccept@CObexTransportControllerBase@@QAEXXZ @ 22 NONAME ; void CObexTransportControllerBase::CancelAccept(void)
+ ?CancelConnect@CObexTransportControllerBase@@QAEXXZ @ 23 NONAME ; void CObexTransportControllerBase::CancelConnect(void)
+ ?CancelTransfers@CObexTransportControllerBase@@QAEXXZ @ 24 NONAME ; void CObexTransportControllerBase::CancelTransfers(void)
+ ?Close@CObexLog@@SAXXZ @ 25 NONAME ; void CObexLog::Close(void)
+ ?CompleteTransfer@CObexReaderBase@@MAEHXZ @ 26 NONAME ; int CObexReaderBase::CompleteTransfer(void)
+ ?CompleteTransfer@CObexWriterBase@@MAEHXZ @ 27 NONAME ; int CObexWriterBase::CompleteTransfer(void)
+ ?Connect@CObexLog@@SAHXZ @ 28 NONAME ; int CObexLog::Connect(void)
+ ?ConnectL@CObexTransportControllerBase@@QAEXXZ @ 29 NONAME ; void CObexTransportControllerBase::ConnectL(void)
+ ?DataLimit@CObexPacket@@QBEGXZ @ 30 NONAME ; unsigned short CObexPacket::DataLimit(void) const
+ ?DoError@CObexTransportControllerBase@@MAEXH@Z @ 31 NONAME ; void CObexTransportControllerBase::DoError(int)
+ ?DoProcess@CObexTransportControllerBase@@MAEXAAVCObexPacket@@@Z @ 32 NONAME ; void CObexTransportControllerBase::DoProcess(class CObexPacket &)
+ ?DoSignalPacketProcessEvent@CObexTransportControllerBase@@MAEXW4TObexPacketProcessEvent@@@Z @ 33 NONAME ; void CObexTransportControllerBase::DoSignalPacketProcessEvent(enum TObexPacketProcessEvent)
+ ?DoTransportUp@CObexTransportControllerBase@@MAEXAAUTObexConnectionInfo@@@Z @ 34 NONAME ; void CObexTransportControllerBase::DoTransportUp(struct TObexConnectionInfo &)
+ ?Dump@CObexPacket@@QBEXXZ @ 35 NONAME ; void CObexPacket::Dump(void) const
+ ?Error@MObexTransportNotify@@QAEXH@Z @ 36 NONAME ; void MObexTransportNotify::Error(int)
+ ?ExtractData@CObexPacket@@QAEHAAVTObexData@@@Z @ 37 NONAME ; int CObexPacket::ExtractData(class TObexData &)
+ ?ExtractRemoteConnectInfo@CObexTransportControllerBase@@QAEHAAVCObexPacket@@AAE1@Z @ 38 NONAME ; int CObexTransportControllerBase::ExtractRemoteConnectInfo(class CObexPacket &, unsigned char &, unsigned char &)
+ ?GetHVText@TObexInternalHeader@@QBEHAAVTDes16@@@Z @ 39 NONAME ; int TObexInternalHeader::GetHVText(class TDes16 &) const
+ ?GetInterface@CObexConnector@@MAEPAXVTUid@@@Z @ 40 NONAME ; void * CObexConnector::GetInterface(class TUid)
+ ?GetInterface@CObexReaderBase@@MAEPAXVTUid@@@Z @ 41 NONAME ; void * CObexReaderBase::GetInterface(class TUid)
+ ?GetInterface@CObexTransportControllerBase@@MAEPAXVTUid@@@Z @ 42 NONAME ; void * CObexTransportControllerBase::GetInterface(class TUid)
+ ?GetInterface@CObexWriterBase@@MAEPAXVTUid@@@Z @ 43 NONAME ; void * CObexWriterBase::GetInterface(class TUid)
+ ?GetObexPacketBufferSize@CObexReaderBase@@IAEHXZ @ 44 NONAME ; int CObexReaderBase::GetObexPacketBufferSize(void)
+ ?GetObexPacketDataLimit@CObexReaderBase@@IAEHXZ @ 45 NONAME ; int CObexReaderBase::GetObexPacketDataLimit(void)
+ ?GetObexPacketHeaderSize@CObexReaderBase@@IAEHXZ @ 46 NONAME ; int CObexReaderBase::GetObexPacketHeaderSize(void)
+ ?HI@TObexInternalHeader@@QBEEXZ @ 47 NONAME ; unsigned char TObexInternalHeader::HI(void) const
+ ?HISize@TObexInternalHeader@@QBEGXZ @ 48 NONAME ; unsigned short TObexInternalHeader::HISize(void) const
+ ?HIType@TObexInternalHeader@@QBE?AW4THeaderType@1@XZ @ 49 NONAME ; enum TObexInternalHeader::THeaderType TObexInternalHeader::HIType(void) const
+ ?HVByteSeq@TObexInternalHeader@@QBEPAEXZ @ 50 NONAME ; unsigned char * TObexInternalHeader::HVByteSeq(void) const
+ ?HVInt@TObexInternalHeader@@QBEHXZ @ 51 NONAME ; int TObexInternalHeader::HVInt(void) const
+ ?HVSize@TObexInternalHeader@@QBEGXZ @ 52 NONAME ; unsigned short TObexInternalHeader::HVSize(void) const
+ ?HexDump@CObexLog@@SAXABVTDesC8@@PBG1PBEH@Z @ 53 NONAME ; void CObexLog::HexDump(class TDesC8 const &, unsigned short const *, unsigned short const *, unsigned char const *, int)
+ ?Init@CObexPacket@@QAEXE@Z @ 54 NONAME ; void CObexPacket::Init(unsigned char)
+ ?InsertData@CObexPacket@@QAEHABVTObexData@@@Z @ 55 NONAME ; int CObexPacket::InsertData(class TObexData const &)
+ ?InsertLocalConnectInfo@CObexTransportControllerBase@@QAEHAAVCObexPacket@@EE@Z @ 56 NONAME ; int CObexTransportControllerBase::InsertLocalConnectInfo(class CObexPacket &, unsigned char, unsigned char)
+ ?IsFinal@CObexPacket@@QBEHXZ @ 57 NONAME ; int CObexPacket::IsFinal(void) const
+ ?IsTransportRestartable@CObexTransportControllerBase@@QBEHXZ @ 58 NONAME ; int CObexTransportControllerBase::IsTransportRestartable(void) const
+ ?IsWriteActive@CObexTransportControllerBase@@QBEHXZ @ 59 NONAME ; int CObexTransportControllerBase::IsWriteActive(void) const
+ ?NewL@CObexActiveReader@@SAPAV1@AAVMObexTransportNotify@@AAVRSocket@@AAUTObexConnectionInfo@@@Z @ 60 NONAME ; class CObexActiveReader * CObexActiveReader::NewL(class MObexTransportNotify &, class RSocket &, struct TObexConnectionInfo &)
+ ?NewL@CObexActiveWriter@@SAPAV1@AAVMObexTransportNotify@@AAVRSocket@@AAUTObexConnectionInfo@@@Z @ 61 NONAME ; class CObexActiveWriter * CObexActiveWriter::NewL(class MObexTransportNotify &, class RSocket &, struct TObexConnectionInfo &)
+ ?NewL@CObexPacket@@SAPAV1@GG@Z @ 62 NONAME ; class CObexPacket * CObexPacket::NewL(unsigned short, unsigned short)
+ ?NewL@CObexTransportControllerBase@@SAPAV1@AAVTObexTransportInfo@@@Z @ 63 NONAME ; class CObexTransportControllerBase * CObexTransportControllerBase::NewL(class TObexTransportInfo &)
+ ?Observer@CObexConnector@@IAEAAVMObexTransportNotify@@XZ @ 64 NONAME ; class MObexTransportNotify & CObexConnector::Observer(void)
+ ?OnCompleteTransfer@CObexReaderBase@@MAEXXZ @ 65 NONAME ; void CObexReaderBase::OnCompleteTransfer(void)
+ ?OnCompleteTransfer@CObexWriterBase@@MAEXXZ @ 66 NONAME ; void CObexWriterBase::OnCompleteTransfer(void)
+ ?Opcode@CObexPacket@@QBEEXZ @ 67 NONAME ; unsigned char CObexPacket::Opcode(void) const
+ ?PacketProcessNotificationEvents@CObexPacket@@QBEIXZ @ 68 NONAME ; unsigned int CObexPacket::PacketProcessNotificationEvents(void) const
+ ?PacketSize@CObexPacket@@QBEGXZ @ 69 NONAME ; unsigned short CObexPacket::PacketSize(void) const
+ ?Process@MObexTransportNotify@@QAEXAAVCObexPacket@@@Z @ 70 NONAME ; void MObexTransportNotify::Process(class CObexPacket &)
+ ?Receive@CObexTransportControllerBase@@QAEXXZ @ 71 NONAME ; void CObexTransportControllerBase::Receive(void)
+ ?ReceivePacket@CObexTransportControllerBase@@QAEAAVCObexPacket@@XZ @ 72 NONAME ; class CObexPacket & CObexTransportControllerBase::ReceivePacket(void)
+ ?Remaining@CObexReaderBase@@MAEHXZ @ 73 NONAME ; int CObexReaderBase::Remaining(void)
+ ?Remaining@CObexWriterBase@@MAEHXZ @ 74 NONAME ; int CObexWriterBase::Remaining(void)
+ ?RemainingExtractSpace@CObexPacket@@QBEGXZ @ 75 NONAME ; unsigned short CObexPacket::RemainingExtractSpace(void) const
+ ?RemainingInsertSpace@CObexPacket@@QBEGXZ @ 76 NONAME ; unsigned short CObexPacket::RemainingInsertSpace(void) const
+ ?RemoteAddr@CObexTransportControllerBase@@QAEXAAVTSockAddr@@@Z @ 77 NONAME ; void CObexTransportControllerBase::RemoteAddr(class TSockAddr &)
+ ?RemovePacketProcessEvents@CObexPacket@@QAEXI@Z @ 78 NONAME ; void CObexPacket::RemovePacketProcessEvents(unsigned int)
+ ?RunL@CObexActiveRW@@MAEXXZ @ 79 NONAME ; void CObexActiveRW::RunL(void)
+ ?Send@CObexTransportControllerBase@@QAEXE@Z @ 80 NONAME ; void CObexTransportControllerBase::Send(unsigned char)
+ ?Send@CObexTransportControllerBase@@QAEXXZ @ 81 NONAME ; void CObexTransportControllerBase::Send(void)
+ ?SendPacket@CObexTransportControllerBase@@QAEAAVCObexPacket@@XZ @ 82 NONAME ; class CObexPacket & CObexTransportControllerBase::SendPacket(void)
+ ?Set@TObexInternalHeader@@QAEXEABVTDesC16@@@Z @ 83 NONAME ; void TObexInternalHeader::Set(unsigned char, class TDesC16 const &)
+ ?Set@TObexInternalHeader@@QAEXEH@Z @ 84 NONAME ; void TObexInternalHeader::Set(unsigned char, int)
+ ?Set@TObexInternalHeader@@QAEXEPAEH@Z @ 85 NONAME ; void TObexInternalHeader::Set(unsigned char, unsigned char *, int)
+ ?SetDeferred@TObexInternalHeader@@QAEXEPAVTPtr8@@HH@Z @ 86 NONAME ; void TObexInternalHeader::SetDeferred(unsigned char, class TPtr8 *, int, int)
+ ?SetFinal@CObexPacket@@QAEXH@Z @ 87 NONAME ; void CObexPacket::SetFinal(int)
+ ?SetHI@TObexInternalHeader@@QAEXE@Z @ 88 NONAME ; void TObexInternalHeader::SetHI(unsigned char)
+ ?SetLegalDataLimit@CObexPacket@@QAEGG@Z @ 89 NONAME ; unsigned short CObexPacket::SetLegalDataLimit(unsigned short)
+ ?SetOpcode@CObexPacket@@QAEXE@Z @ 90 NONAME ; void CObexPacket::SetOpcode(unsigned char)
+ ?SetOwner@CObexTransportControllerBase@@QAEXAAVMObexNotifyExtend@@@Z @ 91 NONAME ; void CObexTransportControllerBase::SetOwner(class MObexNotifyExtend &)
+ ?SetPacketSize@CObexPacket@@QAEXG@Z @ 92 NONAME ; void CObexPacket::SetPacketSize(unsigned short)
+ ?SignalPacketProcessEvent@MObexTransportNotify@@QAEXW4TObexPacketProcessEvent@@@Z @ 93 NONAME ; void MObexTransportNotify::SignalPacketProcessEvent(enum TObexPacketProcessEvent)
+ ?SignalTransportError@CObexTransportControllerBase@@QAEXXZ @ 94 NONAME ; void CObexTransportControllerBase::SignalTransportError(void)
+ ?StartTransfer@CObexReaderBase@@MAEXAAVCObexPacket@@@Z @ 95 NONAME ; void CObexReaderBase::StartTransfer(class CObexPacket &)
+ ?StartTransfer@CObexWriterBase@@MAEXAAVCObexPacket@@@Z @ 96 NONAME ; void CObexWriterBase::StartTransfer(class CObexPacket &)
+ ?TotalSize@TObexData@@QBEGXZ @ 97 NONAME ; unsigned short TObexData::TotalSize(void) const
+ ?TransportUp@MObexTransportNotify@@QAEXAAUTObexConnectionInfo@@@Z @ 98 NONAME ; void MObexTransportNotify::TransportUp(struct TObexConnectionInfo &)
+ ?VerboseLeaveIfErrorL@@YAXABVTDesC8@@PADHH@Z @ 99 NONAME ; void VerboseLeaveIfErrorL(class TDesC8 const &, char *, int, int)
+ ?VerbosePanic@@YAXABVTDesC8@@PADHHPAEABVTDesC16@@@Z @ 100 NONAME ; void VerbosePanic(class TDesC8 const &, char *, int, int, unsigned char *, class TDesC16 const &)
+ ?Write@CObexLog@@SAXABVTDesC8@@0@Z @ 101 NONAME ; void CObexLog::Write(class TDesC8 const &, class TDesC8 const &)
+ ?Write@CObexLog@@SAXABVTDesC8@@ABVTDesC16@@@Z @ 102 NONAME ; void CObexLog::Write(class TDesC8 const &, class TDesC16 const &)
+ ?WriteFormat@CObexLog@@SAXABVTDesC8@@V?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 103 NONAME ; void CObexLog::WriteFormat(class TDesC8 const &, class TRefByValue<class TDesC16 const >, signed char * [1] &)
+ ?WriteFormat@CObexLog@@SAXABVTDesC8@@V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 104 NONAME ; void CObexLog::WriteFormat(class TDesC8 const &, class TRefByValue<class TDesC16 const >, ...)
+ ?WriteFormat@CObexLog@@SAXABVTDesC8@@V?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 105 NONAME ; void CObexLog::WriteFormat(class TDesC8 const &, class TRefByValue<class TDesC8 const >, signed char * [1] &)
+ ?WriteFormat@CObexLog@@SAXABVTDesC8@@V?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 106 NONAME ; void CObexLog::WriteFormat(class TDesC8 const &, class TRefByValue<class TDesC8 const >, ...)
+ ?TransportInfo@CObexTransportControllerBase@@QBEPBVTObexTransportInfo@@XZ @ 107 NONAME ; class TObexTransportInfo const * CObexTransportControllerBase::TransportInfo(void) const
+ ?OnReadActivity@CObexReaderBase@@IAEXXZ @ 108 NONAME ; void CObexReaderBase::OnReadActivity(void)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/eabi/obexcommontransportU.def Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,139 @@
+EXPORTS
+ _Z12VerbosePanicRK6TDesC8PciiPhRK7TDesC16 @ 1 NONAME
+ _Z20VerboseLeaveIfErrorLRK6TDesC8Pcii @ 2 NONAME
+ _ZN11CObexPacket10InsertDataERK9TObexData @ 3 NONAME
+ _ZN11CObexPacket11ExtractDataER9TObexData @ 4 NONAME
+ _ZN11CObexPacket13SetPacketSizeEt @ 5 NONAME
+ _ZN11CObexPacket17SetLegalDataLimitEt @ 6 NONAME
+ _ZN11CObexPacket22AddPacketProcessEventsEj @ 7 NONAME
+ _ZN11CObexPacket25RemovePacketProcessEventsEj @ 8 NONAME
+ _ZN11CObexPacket4InitEh @ 9 NONAME
+ _ZN11CObexPacket4NewLEtt @ 10 NONAME
+ _ZN11CObexPacket8SetFinalEi @ 11 NONAME
+ _ZN11CObexPacket9SetOpcodeEh @ 12 NONAME
+ _ZN11CObexPacketD0Ev @ 13 NONAME
+ _ZN11CObexPacketD1Ev @ 14 NONAME
+ _ZN11CObexPacketD2Ev @ 15 NONAME
+ _ZN13CObexActiveRW4RunLEv @ 16 NONAME
+ _ZN14CObexConnector12GetInterfaceE4TUid @ 17 NONAME
+ _ZN14CObexConnector14BaseConstructLEv @ 18 NONAME
+ _ZN14CObexConnector8ObserverEv @ 19 NONAME
+ _ZN14CObexConnectorC2ER20MObexTransportNotify @ 20 NONAME
+ _ZN14CObexConnectorD0Ev @ 21 NONAME
+ _ZN14CObexConnectorD1Ev @ 22 NONAME
+ _ZN14CObexConnectorD2Ev @ 23 NONAME
+ _ZN15CObexReaderBase12GetInterfaceE4TUid @ 24 NONAME
+ _ZN15CObexReaderBase13StartTransferER11CObexPacket @ 25 NONAME
+ _ZN15CObexReaderBase14BaseConstructLEv @ 26 NONAME
+ _ZN15CObexReaderBase16CompleteTransferEv @ 27 NONAME
+ _ZN15CObexReaderBase18OnCompleteTransferEv @ 28 NONAME
+ _ZN15CObexReaderBase22GetObexPacketDataLimitEv @ 29 NONAME
+ _ZN15CObexReaderBase23GetObexPacketBufferSizeEv @ 30 NONAME
+ _ZN15CObexReaderBase23GetObexPacketHeaderSizeEv @ 31 NONAME
+ _ZN15CObexReaderBase9RemainingEv @ 32 NONAME
+ _ZN15CObexReaderBaseC2EN7CActive9TPriorityER20MObexTransportNotifyR19TObexConnectionInfo @ 33 NONAME
+ _ZN15CObexReaderBaseD0Ev @ 34 NONAME
+ _ZN15CObexReaderBaseD1Ev @ 35 NONAME
+ _ZN15CObexReaderBaseD2Ev @ 36 NONAME
+ _ZN15CObexWriterBase12GetInterfaceE4TUid @ 37 NONAME
+ _ZN15CObexWriterBase13StartTransferER11CObexPacket @ 38 NONAME
+ _ZN15CObexWriterBase14BaseConstructLEv @ 39 NONAME
+ _ZN15CObexWriterBase16CompleteTransferEv @ 40 NONAME
+ _ZN15CObexWriterBase18OnCompleteTransferEv @ 41 NONAME
+ _ZN15CObexWriterBase9RemainingEv @ 42 NONAME
+ _ZN15CObexWriterBaseC2EN7CActive9TPriorityER20MObexTransportNotifyR19TObexConnectionInfo @ 43 NONAME
+ _ZN15CObexWriterBaseD0Ev @ 44 NONAME
+ _ZN15CObexWriterBaseD1Ev @ 45 NONAME
+ _ZN15CObexWriterBaseD2Ev @ 46 NONAME
+ _ZN15TFunctionLoggerC1ERK6TDesC8S2_Pv @ 47 NONAME
+ _ZN15TFunctionLoggerC2ERK6TDesC8S2_Pv @ 48 NONAME
+ _ZN15TFunctionLoggerD1Ev @ 49 NONAME
+ _ZN15TFunctionLoggerD2Ev @ 50 NONAME
+ _ZN17CObexActiveReader4NewLER20MObexTransportNotifyR7RSocketR19TObexConnectionInfo @ 51 NONAME
+ _ZN17CObexActiveReaderD0Ev @ 52 NONAME
+ _ZN17CObexActiveReaderD1Ev @ 53 NONAME
+ _ZN17CObexActiveReaderD2Ev @ 54 NONAME
+ _ZN17CObexActiveWriter4NewLER20MObexTransportNotifyR7RSocketR19TObexConnectionInfo @ 55 NONAME
+ _ZN17CObexActiveWriterD0Ev @ 56 NONAME
+ _ZN17CObexActiveWriterD1Ev @ 57 NONAME
+ _ZN17CObexActiveWriterD2Ev @ 58 NONAME
+ _ZN19TObexInternalHeader11SetDeferredEhP5TPtr8ii @ 59 NONAME
+ _ZN19TObexInternalHeader3SetEhPhi @ 60 NONAME
+ _ZN19TObexInternalHeader3SetEhRK7TDesC16 @ 61 NONAME
+ _ZN19TObexInternalHeader3SetEhi @ 62 NONAME
+ _ZN19TObexInternalHeader5SetHIEh @ 63 NONAME
+ _ZN19TObexInternalHeaderC1Ev @ 64 NONAME
+ _ZN19TObexInternalHeaderC2Ev @ 65 NONAME
+ _ZN20MObexTransportNotify11TransportUpER19TObexConnectionInfo @ 66 NONAME
+ _ZN20MObexTransportNotify24SignalPacketProcessEventE23TObexPacketProcessEvent @ 67 NONAME
+ _ZN20MObexTransportNotify5ErrorEi @ 68 NONAME
+ _ZN20MObexTransportNotify7ProcessER11CObexPacket @ 69 NONAME
+ _ZN28CObexTransportControllerBase10RemoteAddrER9TSockAddr @ 70 NONAME
+ _ZN28CObexTransportControllerBase10SendPacketEv @ 71 NONAME
+ _ZN28CObexTransportControllerBase12CancelAcceptEv @ 72 NONAME
+ _ZN28CObexTransportControllerBase12GetInterfaceE4TUid @ 73 NONAME
+ _ZN28CObexTransportControllerBase13CancelConnectEv @ 74 NONAME
+ _ZN28CObexTransportControllerBase13DoTransportUpER19TObexConnectionInfo @ 75 NONAME
+ _ZN28CObexTransportControllerBase13ReceivePacketEv @ 76 NONAME
+ _ZN28CObexTransportControllerBase15CancelTransfersEv @ 77 NONAME
+ _ZN28CObexTransportControllerBase17AcceptConnectionLEv @ 78 NONAME
+ _ZN28CObexTransportControllerBase18BringTransportDownEv @ 79 NONAME
+ _ZN28CObexTransportControllerBase20SignalTransportErrorEv @ 80 NONAME
+ _ZN28CObexTransportControllerBase22InsertLocalConnectInfoER11CObexPackethh @ 81 NONAME
+ _ZN28CObexTransportControllerBase24ExtractRemoteConnectInfoER11CObexPacketRhS2_ @ 82 NONAME
+ _ZN28CObexTransportControllerBase26DoSignalPacketProcessEventE23TObexPacketProcessEvent @ 83 NONAME
+ _ZN28CObexTransportControllerBase4NewLER18TObexTransportInfo @ 84 NONAME
+ _ZN28CObexTransportControllerBase4SendEh @ 85 NONAME
+ _ZN28CObexTransportControllerBase4SendEv @ 86 NONAME
+ _ZN28CObexTransportControllerBase7DoErrorEi @ 87 NONAME
+ _ZN28CObexTransportControllerBase7ReceiveEv @ 88 NONAME
+ _ZN28CObexTransportControllerBase8ConnectLEv @ 89 NONAME
+ _ZN28CObexTransportControllerBase8SetOwnerER17MObexNotifyExtend @ 90 NONAME
+ _ZN28CObexTransportControllerBase9DoProcessER11CObexPacket @ 91 NONAME
+ _ZN28CObexTransportControllerBaseC2Ev @ 92 NONAME
+ _ZN28CObexTransportControllerBaseD0Ev @ 93 NONAME
+ _ZN28CObexTransportControllerBaseD1Ev @ 94 NONAME
+ _ZN28CObexTransportControllerBaseD2Ev @ 95 NONAME
+ _ZN8CObexLog11WriteFormatERK6TDesC811TRefByValueIK7TDesC16ERSt9__va_list @ 96 NONAME
+ _ZN8CObexLog11WriteFormatERK6TDesC811TRefByValueIK7TDesC16Ez @ 97 NONAME
+ _ZN8CObexLog11WriteFormatERK6TDesC811TRefByValueIS1_ERSt9__va_list @ 98 NONAME
+ _ZN8CObexLog11WriteFormatERK6TDesC811TRefByValueIS1_Ez @ 99 NONAME
+ _ZN8CObexLog5CloseEv @ 100 NONAME
+ _ZN8CObexLog5WriteERK6TDesC8RK7TDesC16 @ 101 NONAME
+ _ZN8CObexLog5WriteERK6TDesC8S2_ @ 102 NONAME
+ _ZN8CObexLog7ConnectEv @ 103 NONAME
+ _ZN8CObexLog7HexDumpERK6TDesC8PKtS4_PKhi @ 104 NONAME
+ _ZNK11CObexPacket10BufferSizeEv @ 105 NONAME
+ _ZNK11CObexPacket10PacketSizeEv @ 106 NONAME
+ _ZNK11CObexPacket20RemainingInsertSpaceEv @ 107 NONAME
+ _ZNK11CObexPacket21RemainingExtractSpaceEv @ 108 NONAME
+ _ZNK11CObexPacket31PacketProcessNotificationEventsEv @ 109 NONAME
+ _ZNK11CObexPacket4DumpEv @ 110 NONAME
+ _ZNK11CObexPacket6OpcodeEv @ 111 NONAME
+ _ZNK11CObexPacket7IsFinalEv @ 112 NONAME
+ _ZNK11CObexPacket9DataLimitEv @ 113 NONAME
+ _ZNK19TObexInternalHeader2HIEv @ 114 NONAME
+ _ZNK19TObexInternalHeader5HVIntEv @ 115 NONAME
+ _ZNK19TObexInternalHeader6HISizeEv @ 116 NONAME
+ _ZNK19TObexInternalHeader6HITypeEv @ 117 NONAME
+ _ZNK19TObexInternalHeader6HVSizeEv @ 118 NONAME
+ _ZNK19TObexInternalHeader9GetHVTextER6TDes16 @ 119 NONAME
+ _ZNK19TObexInternalHeader9HVByteSeqEv @ 120 NONAME
+ _ZNK28CObexTransportControllerBase13IsWriteActiveEv @ 121 NONAME
+ _ZNK28CObexTransportControllerBase22IsTransportRestartableEv @ 122 NONAME
+ _ZNK9TObexData9TotalSizeEv @ 123 NONAME
+ _ZTI14CObexConnector @ 124 NONAME ; #<TI>#
+ _ZTI15CObexReaderBase @ 125 NONAME ; #<TI>#
+ _ZTI15CObexWriterBase @ 126 NONAME ; #<TI>#
+ _ZTI28CObexTransportControllerBase @ 127 NONAME ; #<TI>#
+ _ZTV14CObexConnector @ 128 NONAME ; #<VT>#
+ _ZTV15CObexReaderBase @ 129 NONAME ; #<VT>#
+ _ZTV15CObexWriterBase @ 130 NONAME ; #<VT>#
+ _ZTV28CObexTransportControllerBase @ 131 NONAME ; #<VT>#
+ _ZThn4_N28CObexTransportControllerBase13DoTransportUpER19TObexConnectionInfo @ 132 NONAME ; #<thunk>#
+ _ZThn4_N28CObexTransportControllerBase26DoSignalPacketProcessEventE23TObexPacketProcessEvent @ 133 NONAME ; #<thunk>#
+ _ZThn4_N28CObexTransportControllerBase7DoErrorEi @ 134 NONAME ; #<thunk>#
+ _ZThn4_N28CObexTransportControllerBase9DoProcessER11CObexPacket @ 135 NONAME ; #<thunk>#
+ _ZNK28CObexTransportControllerBase13TransportInfoEv @ 136 NONAME
+ _ZN15CObexReaderBase14OnReadActivityEv @ 137 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/group/bld.inf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,51 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+*/
+
+PRJ_EXPORTS
+
+// Files intended for 3rd party use go into \epoc32\include. (NB This includes
+// files which must be presented to 3rd parties for compatibility reasons.)
+../public/mobexnotify.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(mobexnotify.h)
+
+// Files which are needed or which may be needed to make a transport
+// controller go into \epoc32\include\obex\transport.
+../public/obexactivereader.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexactivereader.h)
+../public/obexactivewriter.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexactivewriter.h)
+../public/mobextransportnotify.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/mobextransportnotify.h)
+../public/obexconnector.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexconnector.h)
+../public/obextransportcontrollerbase.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obextransportcontrollerbase.h)
+../public/obextransport.hrh /epoc32/include/obex/transport/obextransport.hrh
+../public/ObexWriterBase.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexwriterbase.h)
+../public/ObexReaderBase.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/transport/obexreaderbase.h)
+
+// Files which are internal to Symbian go into \epoc32\include\obex\internal.
+../public/obexactiverw.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexactiverw.h)
+../public/obexdata.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexdata.h)
+../public/obexinternalheader.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexinternalheader.h)
+../public/obexpacket.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexpacket.h)
+../public/obexinternalconstants.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obexinternalconstants.h)
+../public/obextransportconstants.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/obextransportconstants.h)
+../public/mobexnotifyextend.h SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(obex/internal/mobexnotifyextend.h)
+
+
+PRJ_MMPFILES
+obexcommontransport.MMP
+
+PRJ_TESTMMPFILES
+../test/headercheck/group/t_obextransportheadercheck.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/group/obexcommontransport.MMP Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,61 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// obex common transport classes mmp file
+// ObexCommonTransport.dll Obex common transport classes
+//
+//
+
+/**
+ @file
+*/
+
+target obexcommontransport.dll //Recommended unpaged
+
+CAPABILITY All -Tcb
+TARGETTYPE dll
+
+uid 0x1000008d 0x1020dfff
+
+SOURCEPATH ../src
+SOURCE obextransportcontrollerbase.cpp
+SOURCE obexpacket.cpp
+SOURCE obexdata.cpp
+SOURCE obexinternalheader.cpp
+SOURCE obexconnectdata.cpp
+SOURCE ObexTransportUtil.cpp
+SOURCE obexconnector.cpp
+SOURCE obexactiverw.cpp
+SOURCE mobextransportnotify.cpp
+SOURCE obexactivereader.cpp
+SOURCE obexactivewriter.cpp
+SOURCE ObexReaderBase.cpp
+SOURCE ObexWriterBase.cpp
+
+// Logging functions
+SOURCE logengine.cpp
+
+USERINCLUDE ../inc
+USERINCLUDE ../../common
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+library euser.lib
+library ecom.lib
+library esock.lib
+
+VENDORID 0x70000001
+
+#include <comms-infras/commsdebugutility.mmh>
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/inc/ObexTransportUtil.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,26 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXTRANSPORTUTIL_H
+#define __OBEXTRANSPORTUTIL_H
+
+#include <e32std.h>
+#include <ecom/ecom.h>
+
+//Used to push a pointer array on to the cleanup stack
+//ensuring that it will be reset and destroyed when popped
+void CleanupResetAndDestroyPushL(RImplInfoPtrArray& aArray);
+
+#endif // __OBEXTRANSPORTUTIL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/inc/obexconnectdata.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,44 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXCONNECTDATA_H__
+#define __OBEXCONNECTDATA_H__
+
+#include <e32def.h>
+#include <obex/internal/obexdata.h>
+
+/**
+@file
+
+TObexConnectData contains the non-standard connect information from connect and connect
+response packets.
+*/
+NONSHARABLE_CLASS(TObexConnectData) : public TObexData
+ {
+public:
+ TObexConnectData ();
+
+protected:
+ // Implementation of TObexData functions
+ virtual TUint16 DoTotalSize () const; //< Total size of header
+ virtual TUint16 ParseIn (TUint8* aSource, const TUint16 aMaxSize);
+ virtual TUint16 WriteOut (TUint8* aDest, const TUint16 aMaxSize) const;
+public:
+ TUint8 iVersion;
+ TUint8 iFlags;
+ TUint16 iMaxPacketLength;
+ };
+
+#endif // __OBEXCONNECTDATA_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/inc/obextransportfaults.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,34 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXTRANSPORTFAULTS_H
+#define __OBEXTRANSPORTFAULTS_H
+/**
+@file
+@internalComponent
+*/
+
+enum TObexTransportFaultCode
+ {
+ ETransportNullPointer = 0,
+ EStringOverflow = 1,
+ EPacketOverrun = 2,
+ EInvalidHeaderSize = 3,
+ EInvalidPacketSize = 4,
+ EDataLimitLargerThanBuffer = 5,
+ EOwnerAlreadySet = 6,
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/ObexReaderBase.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,79 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXREADERBASE_H__
+#define __OBEXREADERBASE_H__
+
+#include <obex/internal/obexactiverw.h>
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+/**
+CObexReaderBase provides obex specific reader behaviour for concrete readers to use.
+Derive from this class when providing a reader for a specific transport.
+
+In a concrete reader the following things must be done:
+(a) In DoTransfer a read data transfer is issued over the reader's transport
+(b) GetMaxPacketSize must return the maximum packet size that can be received
+(c) GetInitialPacketSize must return a packet size that can be used in the event that the packet
+size of the packet to be read is not yet known (for example irda and bt use the obexpacketheadersize and usb
+uses the buffer size of the packet created to receive the data)
+(d)The NewL function must call BaseConstructL(). This is future proofing in the event that the iFuture1 variable is used
+and requires initialisation
+*/
+class CObexReaderBase : public CObexActiveRW
+ {
+public:
+ IMPORT_C virtual ~CObexReaderBase();
+
+protected:
+ IMPORT_C CObexReaderBase(TPriority aPriority, MObexTransportNotify& aOwner, TObexConnectionInfo& aInfo);
+ IMPORT_C void BaseConstructL();
+
+protected: // from CObexActiveRW
+ IMPORT_C virtual void StartTransfer (CObexPacket& aPacket);
+ IMPORT_C TBool CompleteTransfer ();
+ IMPORT_C void OnReadActivity();
+ IMPORT_C virtual void OnCompleteTransfer();
+ IMPORT_C TInt Remaining();
+ IMPORT_C TInt GetObexPacketBufferSize();
+ IMPORT_C TInt GetObexPacketHeaderSize();
+ IMPORT_C TInt GetObexPacketDataLimit();
+ /** This method issues either a read of data over the relevant transport object.
+ @see NewRequest*/
+ virtual void DoTransfer () =0;
+
+ //ExtensionPattern
+ IMPORT_C virtual TAny* GetInterface(TUid aUid);
+ /** Returns the maximum packet size that can be received */
+ virtual TInt GetMaxPacketSize() = 0;
+
+ /** Returns a initial packet size when the packet size of iPacket is not know. This is used
+ when determining the remaining bytes to be read. */
+ virtual TInt GetInitialPacketSize() = 0;
+
+private:
+ TBool iGotHeader;
+ TInt iTransferError;
+
+ //For future data expansion
+ TAny* iFuture1;
+ };
+
+#endif // __OBEXREADERBASE_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/ObexWriterBase.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,64 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXWRITERBASE_H__
+#define __OBEXWRITERBASE_H__
+
+#include <obex/internal/obexactiverw.h>
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+/**
+CObexWriterBase provides obex specific writer behaviour for concrete writers to use.
+Derive from this class when providing a writer for a specific transport.
+
+In a concrete writer the following things must be done:
+(a)In DoTransfer a write transfer is issued over the writer's transport
+(b)The NewL function must call BaseConstructL(). This is future proofing in the event that the iFuture1 variable is used
+and requires initialisation
+*/
+class CObexWriterBase : public CObexActiveRW
+ {
+public:
+ IMPORT_C virtual ~CObexWriterBase();
+
+protected:
+ IMPORT_C CObexWriterBase(TPriority aPriority, MObexTransportNotify& aOwner, TObexConnectionInfo& aInfo);
+ IMPORT_C void BaseConstructL();
+
+protected: // from CObexActiveRW
+ IMPORT_C virtual TBool CompleteTransfer();
+ IMPORT_C virtual void OnCompleteTransfer();
+ IMPORT_C virtual void StartTransfer(CObexPacket& aPacket);
+ IMPORT_C virtual TInt Remaining();
+ /**
+ This method issues a write of data over the relevant transport object.
+ @see NewRequest
+ */
+ virtual void DoTransfer () =0;
+
+ //ExtensionPattern
+ IMPORT_C virtual TAny* GetInterface(TUid aUid);
+
+protected: // owned
+ // For future data expansion
+ TAny* iFuture1;
+ };
+
+#endif // __OBEXWRITERBASE_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/mobexnotify.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,43 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __MOBEXNOTIFY_H__
+#define __MOBEXNOTIFY_H__
+
+#include <e32std.h>
+
+class CObexPacket;
+
+/**
+@internalComponent
+
+This class is only for internal use.
+
+Originally it provided the call back interface for anything owned by CObex.
+Note: This is an internal class which is not intended for use outside of
+the Transport<->Obex interface. Even where access rules allow it, external
+users should not call these functions as their implementation may change.
+*/
+NONSHARABLE_CLASS(MObexNotify)
+
+ {
+public:
+ virtual void Process(CObexPacket &aPacket) =0;
+ virtual void Error(TInt aError) =0;
+ virtual void TransportUp() =0;
+ virtual void TransportDown(TBool aForceTransportDeletion) =0;
+ };
+
+#endif // __MOBEXNOTIFY_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/mobexnotifyextend.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,49 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef MOBEXNOTIFYEXTEND_H
+#define MOBEXNOTIFYEXTEND_H
+
+/**
+@file
+@released
+@internalTechnology
+*/
+
+#include <e32std.h>
+#include <mobexnotify.h>
+#include <obex/internal/obextransportconstants.h>
+
+class CObexPacket;
+/**
+Provides the call back interface for anything using CObexTransport (ie CObex).
+Note: This is an internal class which is not intended for use outside of
+the Transport<->Obex interface. Even where access rules allow it, external
+users should not call these functions as their implementation may change.
+*/
+NONSHARABLE_CLASS(MObexNotifyExtend) : public MObexNotify
+ {
+public:
+ // original functions as found in MObexNotify
+ virtual void Process(CObexPacket& aPacket) =0;
+ virtual void Error(TInt aError) =0;
+ virtual void TransportUp() =0;
+
+ // This is non-pure as derivers may not care about any events so we
+ // don't want to force them into handling them.
+ virtual void SignalPacketProcessEvent(TObexPacketProcessEvent /*aEvent*/){};
+ };
+
+#endif // MOBEXNOTIFYEXTEND_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/mobextransportnotify.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,52 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __MOBEXTRANSPORTNOTIFY_H__
+#define __MOBEXTRANSPORTNOTIFY_H__
+
+#include <e32std.h>
+#include <obex/internal/obextransportconstants.h>
+
+class CObexPacket;
+struct TObexConnectionInfo;
+
+/**
+Provides the call back interface for anything owned by CObexTransportControllerBase
+(ie CObexConnector or CObexActiveRW derived classes).
+Note: This is an internal class which is not intended for use outside of
+the Transport<->Connector/Reader/Writer interface. Even where access rules allow it, external
+users should not call these functions as their implementation may change.
+
+@publishedPartner
+@released
+*/
+NONSHARABLE_CLASS(MObexTransportNotify)
+ {
+
+public:
+ IMPORT_C void Process(CObexPacket &aPacket) ;
+ IMPORT_C void Error(TInt aError);
+ IMPORT_C void TransportUp(TObexConnectionInfo& aInfo) ; // Call back to start the obex sessio
+ IMPORT_C void SignalPacketProcessEvent(TObexPacketProcessEvent aEvent);
+
+protected:
+ virtual void DoProcess(CObexPacket &aPacket) =0;
+ virtual void DoError(TInt aError) =0;
+ virtual void DoTransportUp(TObexConnectionInfo& aInfo) =0;
+ virtual void DoSignalPacketProcessEvent(TObexPacketProcessEvent aEvent) =0;
+
+ };
+
+#endif // __MOBEXTRANSPORTNOTIFY_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexactivereader.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,51 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __OBEXACTIVEREADER_H__
+#define __OBEXACTIVEREADER_H__
+
+#include <obex/transport/obexreaderbase.h>
+
+class RSocket;
+
+/**
+Functionality specific to reading from a socket
+@internalTechnology
+*/
+NONSHARABLE_CLASS(CObexActiveReader) : public CObexReaderBase
+ {
+public:
+ IMPORT_C static CObexActiveReader* NewL(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo);
+ IMPORT_C ~CObexActiveReader ();
+
+private:
+ CObexActiveReader (MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo);
+
+private: // from CObexReaderBase
+ virtual void DoCancel ();
+ virtual void DoTransfer ();
+ virtual TInt GetMaxPacketSize();
+ virtual TInt GetInitialPacketSize();
+
+private:
+ RSocket& iSocket;
+ };
+
+#endif // __OBEXACTIVEREADER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexactiverw.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,123 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXACTIVERW_H__
+#define __OBEXACTIVERW_H__
+
+/**
+@file
+@internalTechnology
+*/
+
+#include <e32def.h>
+#include <e32base.h>
+
+class MObexTransportNotify;
+struct TObexConnectionInfo;
+class CObexPacket;
+
+/**
+Base class for a specific transport's active reader and writer classes.
+The derived classes are responsible for sending and receiving data for their
+transport.
+
+@see CObexReaderBase
+@see CObexWriterBase
+*/
+NONSHARABLE_CLASS(CObexActiveRW) : public CActive
+ {
+public:
+ CObexActiveRW(TPriority aP, MObexTransportNotify& aOwner, TObexConnectionInfo& aInfo);
+ ~CObexActiveRW();
+ void Transfer(CObexPacket& aPacket);
+
+protected: // functions to be implemented by derived classes
+ /**
+ This method does any required initialisation of data for the transfer,
+ including the received, aPacket, before calling NewRequest.
+
+ @see Transfer
+ @see NewRequest(CObexPacket& aPacket)
+ @param aPacket The packet to read into or written
+ */
+ virtual void StartTransfer(CObexPacket& aPacket) =0; //called by non virtual Transfer
+
+ /**
+ This method issues either a read or write of data over the relevant
+ transport object. This method is called from NewRequest.
+
+ @see NewRequest
+ */
+ virtual void DoTransfer () =0;
+
+ /**
+ This method compares the number of bytes, iCount, read/ written, against
+ the packet size. In the case of a write, ETrue is returned if all the
+ bytes have been written, otherwise EFalse.
+
+ For reads, check if the header is received and if so assign iPacketSize
+ with the packet size indicated in the header of the received packet. Note
+ that the claimed packet size must be greater than the required obex header
+ size and no more than the maximum packet size this transport handles.
+
+ @see CObexTransportControllerBase::Process()
+ @return TBool return ETrue if the transfer has completed else EFalse
+ */
+ virtual TBool CompleteTransfer () =0; // check if packet read/write has completed
+
+ /**
+ This method is called when a transfer is complete. Any actions associated
+ with completion of a transfer should be performed here, for instance
+ sending the packet to the owner of the reader to be processed.
+ */
+ virtual void OnCompleteTransfer() =0; // perform action associated with read/write completion
+
+ /**
+ Return the number bytes left to transfer
+ @return TInt the number of bytes left to be transferred
+ */
+ virtual TInt Remaining () =0; // how much is left to transfer
+
+ //function used by derived classes
+ void NewRequest (CObexPacket& aPacket); // start new packet send/receive
+
+ //RunL for derived classes
+ IMPORT_C void RunL ();
+
+// Data
+protected:
+ /**The owner of the derived reader or writer class. Required at construction.*/
+ MObexTransportNotify& iOwner;
+
+ /**The obex packet, received from the owner, that will be sent or written into iLocation.*/
+ CObexPacket* iPacket;
+
+ /**A pointer to the iPacket buffer at the point where data is to be written
+ from or read into. The maximum length is the remaining bytes to be read or
+ written. Data is read from this buffer into the transport, or written from
+ the transport into this buffer. */
+ TPtr8 iLocation;
+
+ /**The number of bytes that have been read or written*/
+ TInt iCount;
+
+ /**The size of the obex packet */
+ TInt iPacketSize;
+
+ /**Is true if the transport is a packet based transport*/
+ TBool iPacketBased;
+ };
+
+#endif // __OBEXACTIVERW_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexactivewriter.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,53 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __OBEXACTIVEWRITER_H__
+#define __OBEXACTIVEWRITER_H__
+
+#include <obex/transport/obexwriterbase.h>
+#include <obex/transport/obexconnector.h>
+
+class RSocket;
+
+/**
+Functionality specific to writing to a socket.
+@internalTechnology
+*/
+NONSHARABLE_CLASS(CObexActiveWriter) : public CObexWriterBase
+ {
+public:
+ IMPORT_C static CObexActiveWriter* NewL(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo);
+ IMPORT_C ~CObexActiveWriter();
+
+private:
+ CObexActiveWriter(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo);
+
+private: // from CObexWriterBase
+ virtual void StartTransfer(CObexPacket& aPacket);
+ virtual void DoCancel();
+ virtual void DoTransfer();
+
+private:
+ TInt iTransportWriteLimit;
+ TObexConnectionInfo iInfo; // used to find out transport limits per transfer
+ RSocket& iSocket;
+ };
+
+#endif // __OBEXACTIVEWRITER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexconnector.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,127 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines the interface to an obex connector
+//
+//
+
+#ifndef __OBEXCONNECTOR_H__
+#define __OBEXCONNECTOR_H__
+
+#include <e32base.h>
+
+class MObexTransportNotify;
+
+/**
+@publishedPartner
+@released
+*/
+struct TObexConnectionInfo
+ {
+ enum TSocketType
+ {
+ ESocketPacket,
+ ESocketStream,
+ EUsbStream,
+ };
+ TSocketType iSocketType;
+ TInt iMaxSendSize;
+ TInt iMaxRecvSize;
+ };
+
+/**
+Base type for OBEX connectors
+To make an OBEX protocol connector: Derive from this class and override the
+pure virtual functions with the relevent implementation
+
+@publishedPartner
+@released
+*/
+class CObexConnector : public CBase
+ {
+public:
+ /**
+ This function is called as a result of an Obex client connect being
+ issued. This function may either
+ 1. attempt to make a transport level connection with the transport level
+ of an Obex server. For example, in the case of socket based transports, a
+ socket is opened and a socket connect is issued.
+ 2. check that a transport link exists. For example in the case of the usb
+ standard transport the connection may already be there
+ In both cases, if successful, the connector will notify its owner that the
+ transport is up. Otherwise the connector may 'error' the owner or leave as
+ appropriate.
+
+ @see MObexTransportNotify::TransportUp()
+ @see MObexTransportNotify::Error()
+ */
+ virtual void ConnectL()=0;
+
+ /**
+ This function cancels actions taken as a result of the ConnectL() request
+ @see ConnectL()
+ */
+ virtual void CancelConnect ()=0 ;
+
+ /**
+ This function is called as a result of an Obex server accept being issued.
+ This function will start a transport object listening for a connect from
+ the transport layer of an Obex client, if the transport layer has not
+ already been established.
+
+ In both cases, if successful, the connector will notify its owner that the
+ transport is up. Otherwise the connector may 'error' the owner or leave as
+ appropriate.
+ @see MObexTransportNotify::TransportUp()
+ @see MObexTransportNotify::Error()
+ */
+ virtual void AcceptL ()=0 ;
+
+ /**
+ This function cancels actions taken as a result of the AcceptL() request
+
+ @see AcceptL()
+ */
+ virtual void CancelAccept ()=0;
+
+ /**
+ This function takes down the transport link. If there are reasons why the
+ transport link cannot be taken down, then the function should return
+ EFalse.
+ */
+ virtual TBool BringTransportDown()=0;
+
+ /**
+ This function is a notification from the obex protocol layer that a
+ transport error has occured. Set any transport specific error condition
+ flags in this function.
+ */
+ virtual void SignalTransportError()=0;
+
+public:
+ IMPORT_C CObexConnector(MObexTransportNotify& aObserver);
+ IMPORT_C ~CObexConnector();
+
+protected:
+ IMPORT_C virtual TAny* GetInterface(TUid aUid);
+ IMPORT_C void BaseConstructL();
+ IMPORT_C MObexTransportNotify& Observer();
+
+private: // owned
+ TAny* iFuture1;
+
+private: // unowned
+ MObexTransportNotify& iObserver;
+ };
+
+#endif // __OBEXCONNECTOR_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexdata.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,45 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __OBEXDATA_H__
+#define __OBEXDATA_H__
+
+#include <e32def.h>
+
+class CObexPacket; // Forward
+
+/**
+Abstraction for any struct that lives inside packet payload areas.
+@internalTechnology
+*/
+NONSHARABLE_CLASS(TObexData)
+ {
+friend class CObexPacket;
+
+public:
+ IMPORT_C TUint16 TotalSize () const;
+
+protected:
+ virtual TUint16 DoTotalSize() const = 0;
+ virtual TUint16 ParseIn (TUint8* aSource, const TUint16 aMaxSize) =0;
+ virtual TUint16 WriteOut (TUint8* aDest, const TUint16 aMaxSize) const =0;
+ };
+
+#endif // __OBEXDATA_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexinternalconstants.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,38 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXINTERNALCONSTANTS_H
+#define __OBEXINTERNALCONSTANTS_H
+
+#include <e32def.h>
+
+/**
+@internalTechnology
+@released
+*/
+
+// Constants describing miniumum, maximum and default OBEX pakcet sizes
+// These are set to maintain backwards compatibility, so change with caution!
+
+const TUint16 KObexPacketMaxSize = 0xffff; // Maximum possible packet size (64kB)
+const TUint16 KObexPacketDefaultSize = 4000; // Fixed buffer size in previous implementations
+const TUint16 KObexPacketMinSize = 255; // Minimum legal size of a pakcet
+
+// ########## Constant Data ##########
+
+const TUint8 KObexPacketFinalBit = 0x80; // Most signif. Bit is final flag.//used only by obexpacket
+const TUint16 KObexPacketHeaderSize = 3; // Head = Opcode (1) + Size (2) //this const is used all over
+
+#endif // __OBEXINTERNALCONSTANTS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexinternalheader.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,129 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __OBEXINTERNALHEADER_H__
+#define __OBEXINTERNALHEADER_H__
+
+#include <e32def.h>
+#include <e32cmn.h>
+#include <obex/internal/obexdata.h>
+
+// ########## Constant Data ##########
+
+const TUint8 KObexHeaderHILongSize = 3; // Unicode or Byte sequence
+const TUint8 KObexHeaderHIShortSize = 1; // Byte of 4 byte headers
+
+/**
+Two parts to headers: header IDs (HI) and header values (HV).
+There are some strange things going on in this class, due it sourcing data
+(HV) from either obex or epoc, and having to then either stream it obex or
+return it to epoc. Might be tidier having a finer class hierarcy, but the
+implemented method does allow for complete generality.
+
+Partly due to this strangeness, this is only used internally. There is also
+a CObexHeader class which is used for the external representation of a data
+header.
+@internalTechnology
+@see CObexHeader
+*/
+NONSHARABLE_CLASS(TObexInternalHeader) : public TObexData
+
+ {
+public:
+ // Header specific types
+ typedef TUint8 THeaderID;
+ IMPORT_C enum THeaderType
+ {
+ EUnicode = 0x00,
+ EByteSeq = 0x40,
+ E1Byte = 0x80,
+ E4Byte = 0xC0
+ };
+
+ IMPORT_C enum TWellKnownHI
+ {
+ ECount = 0x00 | E4Byte,
+ EName = 0x01 | EUnicode,
+ EType = 0x02 | EByteSeq,
+ ELength = 0x03 | E4Byte,
+ ETime = 0x04 | EByteSeq,
+ EDescription = 0x05 | EUnicode,
+ ETarget = 0x06 | EByteSeq,
+ EHttp = 0x07 | EByteSeq,
+ EBody = 0x08 | EByteSeq,
+ EEndOfBody = 0x09 | EByteSeq,
+ EWho = 0x0A | EByteSeq,
+ EConnectionID = 0x0B | E4Byte,
+ EAppParam = 0x0C | EByteSeq,
+ EAuthChallenge = 0x0D | EByteSeq,
+ EAuthResponse = 0x0E | EByteSeq,
+ ECreatorID = 0x0F | E4Byte,
+ EWanUUID = 0x10 | EByteSeq,
+ EObjectClass = 0x11 | EByteSeq
+ };
+
+ IMPORT_C enum THVRepresentation
+ {
+ EHVObexDefault,
+ EHVMachineText,
+ EHVInt,
+ EHVDefered
+ };
+
+ IMPORT_C TObexInternalHeader ();
+
+ // Setters
+ IMPORT_C void SetHI (THeaderID aHID);
+ IMPORT_C void Set (THeaderID aHID, TInt aValue);
+ IMPORT_C void Set (THeaderID aHID, TUint8* aHV, TInt aHVSize);
+ IMPORT_C void Set (THeaderID aHID, const TDesC& aString);
+ IMPORT_C void SetDeferred (THeaderID aHID, TPtr8* aDataInserter, TInt aMinSize, TInt aMaxSize = 0);
+
+ // Getters
+ IMPORT_C THeaderID HI () const;
+ IMPORT_C THeaderType HIType () const;
+ IMPORT_C TInt HVInt () const;
+ IMPORT_C TUint8* HVByteSeq () const;
+ IMPORT_C TInt GetHVText (TDes& aString) const;
+
+ IMPORT_C TUint16 HISize () const;
+ IMPORT_C TUint16 HVSize () const;
+
+protected:
+ // Implementation of TObexData functions
+ TUint16 DoTotalSize () const; // Total size of header
+ virtual TUint16 ParseIn (TUint8* aSource, const TUint16 aMaxSize);
+ virtual TUint16 WriteOut (TUint8* aDest, const TUint16 aMaxSize) const;
+
+private:
+ THeaderID iHI;
+ union
+ {
+ TUint8* iObex;
+ TText* iMachine;
+ TInt iInt;
+ TPtr8* iDefered;
+ } iHV;
+ THVRepresentation iHVRep;
+ TUint16 iHVSize;
+ TUint16 iHVMaxSize; // Used for defered data entry
+ }; // TObexInternalHeader
+
+#endif // __OBEXINTERNALHEADER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obexpacket.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,91 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __OBEXPACKET_H__
+#define __OBEXPACKET_H__
+
+#include <e32base.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <obex/internal/obextransportconstants.h>
+#include <obextypes.h>
+
+class TObexData;
+
+/**
+Packets, which are the basic unit transfered between CObex and the transport
+@internalTechnology
+*/
+NONSHARABLE_CLASS(CObexPacket) : public CBase
+ {
+friend class CObexActiveRW;
+
+public:
+ IMPORT_C ~CObexPacket ();
+ IMPORT_C static CObexPacket* NewL (TUint16 aBufferSize, TUint16 aDataLimit);
+
+ // Functions to set packet data
+ IMPORT_C void Init (TObexOpcode aOpcode);
+
+ IMPORT_C TObexOpcode Opcode () const;
+ IMPORT_C void SetOpcode (TObexOpcode aOpcode);
+
+ IMPORT_C TBool IsFinal () const;
+ IMPORT_C void SetFinal (TBool aFinal = ETrue);
+
+ // Get/Set the current packet size
+ // These refer size encoded in the OBEX packet itself (not the buffer used to contain the packet)
+ IMPORT_C TUint16 PacketSize () const;
+ IMPORT_C void SetPacketSize (TUint16 aSize);
+
+ // Get/Set the buffer size/data limit
+ IMPORT_C TUint16 SetLegalDataLimit (TUint16 aSize);
+ IMPORT_C TUint16 DataLimit () const;
+ IMPORT_C TUint16 BufferSize () const;
+
+ // Setters & Getters, payload
+ IMPORT_C TBool InsertData (const TObexData& aHeader);
+ IMPORT_C TBool ExtractData (TObexData& aHeader);
+ IMPORT_C TUint16 RemainingInsertSpace () const;
+ IMPORT_C TUint16 RemainingExtractSpace () const;
+ IMPORT_C void AddPacketProcessEvents(TObexPacketProcessEvents aEvents);
+ IMPORT_C void RemovePacketProcessEvents(TObexPacketProcessEvents aEvents);
+ IMPORT_C TObexPacketProcessEvents PacketProcessNotificationEvents() const;
+ IMPORT_C void Dump() const;
+
+private:
+ CObexPacket (TUint16 aBufferSize, TUint16 aDataLimit);
+ void ConstructL ();
+
+ inline const TUint8* Payload () const {return (&iBuffer[KObexPacketHeaderSize]);};
+ inline TUint8* Payload () {return (&iBuffer[KObexPacketHeaderSize]);};
+ inline TUint16 PayloadSize () const {return (STATIC_CAST(TUint16, PacketSize () - KObexPacketHeaderSize));};
+
+
+// Data
+private:
+ TUint16 iBufferSize; // how big the buffer actually is
+ TUint16 iDataLimit; // how large the data can be (usually set per conenction)
+ TUint8* iInsertPoint;
+ TUint8* iExtractPoint;
+ TUint8* iBuffer;
+ TObexPacketProcessEvents iNotificationEvents;
+ }; // CObexPacket
+
+#endif // __OBEXPACKET_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obextransport.hrh Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,24 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Definition of interface UID for OBEX transport controller plugins.
+// Definition of interface UID for OBEX transport controller plugins.
+//
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+#define KObexTransportInterfaceUid 0x10208755
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obextransportconstants.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,71 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXTRANSPORTCONSTANTS_H__
+#define __OBEXTRANSPORTCONSTANTS_H__
+
+/**
+@file
+@internalTechnology
+*/
+
+#include <e32base.h>
+
+const TUint8 KObexConnectionIDLength = 4;
+
+typedef TBuf8<KObexConnectionIDLength> TConnId;
+typedef TBuf8<16> TRequestDigest;
+
+/**
+This enum is for INTERNAL USE ONLY.
+
+The enum values are signals sent between layers in OBEX. Some of them result
+in user-visible notifications and some don't.
+
+Their numerical values are not significant, with the exception of the fact
+that EObexFinalPacketStarted must have a lower numerical value than
+EObexFinalPacketFinished. If both of these signals are outstanding on a packet
+at once, the user will be notified in numerical-value order. The 'final packet
+observer' API requires that the signals are given to the user in the order
+'final packet started' then 'final packet finished'.
+
+These are to be used as fields in a bitmask, so a value must always bit set.
+*/
+enum TObexPacketProcessEvent
+ {
+ /** The transport layer has started to write a final packet. */
+ EObexFinalPacketStarted = 0x1,
+
+ /** The transport layer has finished writing a final packet. */
+ EObexFinalPacketFinished = 0x2,
+
+ /** A packet has finished being written. */
+ EObexWriteCompleted = 0x4,
+
+ /** A packet has finished being written. This is signalled upwards by the
+ transport layer last of all because it signals the completion of the
+ sending of an ACK to a disconnect command. The OBEX server uses this
+ signal to progress the disconnection. */
+ EObexWriteCompletedFinal = 0x8,
+
+ /** Read activity has been detected. This is signalled upwards by the
+ transport layer AT LEAST when the first read of a new Obex operation
+ is detected. */
+ EObexReadActivityDetected = 0x10,
+ };
+
+typedef TUint TObexPacketProcessEvents;
+
+#endif //__OBEXTRANSPORTCONSTANTS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/public/obextransportcontrollerbase.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,145 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXTRANSPORTCONTROLLERBASE_H__
+#define __OBEXTRANSPORTCONTROLLERBASE_H__
+
+#include <e32base.h>
+#include <obex/transport/mobextransportnotify.h>
+#include <obex/transport/obexconnector.h>
+#include <obex/internal/obextransportconstants.h>
+#include <obex/transport/obextransport.hrh>
+#include <obextypes.h>
+
+class CObexPacket;
+class MObexNotifyExtend;
+class TSockAddr;
+class CObexActiveRW;
+class TObexTransportInfo;
+
+/**
+@file
+@publishedPartner
+@released
+*/
+
+/**
+Interface UID for transport controllers.
+Transport controllers are instantiations of this interface.
+*/
+const TInt KObexTransportControllerInterfaceUid = KObexTransportInterfaceUid;
+
+/**
+Abstraction for transport controller implementations. Defines an interface to
+be used by Obex protocol layer as the facade to the transport layer.
+
+In a concrete transport controller's NewL, the following things must be done:
+(a) CObexTransportControllerBase::iConnector must be assigned to a
+CObexConnector-derived type. (This may be reliant on the TObexTransportInfo
+object passed in at this time.) iConnector is owned by
+CObexTransportControllerBase.
+(b) CObexTransportControllerBase::iTransportInfo must be assigned to a
+persistent (i.e. heap-based) TObexTransportInfo or derived type. The derived
+transport controller may cast the TObexTransportInfo given at construction
+time to a known derived type and copy the data from it to the new instance on
+the heap. Note that ownership of the given TObexTransportInfo *remains with
+the client*. iTransportInfo is then owned by CObexTransportControllerBase.
+
+In a concrete transport controller's NewTransportL, two instances of types
+derived from CObexActiveRW must be created, and stored in
+CObexTransportControllerBase::iActiveReader and
+CObexTransportControllerBase::iActiveWriter. CObexTransportControllerBase owns
+these.
+*/
+class CObexTransportControllerBase : public CBase, public MObexTransportNotify
+ {
+public:
+ IMPORT_C static CObexTransportControllerBase* NewL(TObexTransportInfo& aTransportInfo);
+ IMPORT_C ~CObexTransportControllerBase();
+
+public:
+ IMPORT_C void SetOwner(MObexNotifyExtend& aOwner);
+
+ //delegated to activerw class
+ IMPORT_C CObexPacket& SendPacket () ; //< Access packet buffers
+ IMPORT_C CObexPacket& ReceivePacket ();
+ IMPORT_C void Send (); //< Actually carry out transfer
+ IMPORT_C void Send (TObexOpcode aOpcode); //< Prepare and send a 3 byte packet
+ IMPORT_C void Receive ();
+
+ IMPORT_C TBool IsWriteActive () const; //< is the ActiveWriter busy
+ IMPORT_C TInt InsertLocalConnectInfo (CObexPacket &aPacket, TUint8 aVersion, TUint8 aFlags);
+ IMPORT_C TBool ExtractRemoteConnectInfo (CObexPacket &aPacket, TUint8& aVersion, TUint8& aFlags);
+ IMPORT_C void CancelTransfers();
+
+ //delegated to connector class
+ IMPORT_C void ConnectL ();
+ IMPORT_C void CancelConnect();
+ IMPORT_C void AcceptConnectionL();
+ IMPORT_C void CancelAccept();
+ IMPORT_C TBool BringTransportDown();
+ IMPORT_C void SignalTransportError();
+
+ //public non-virtual methods to aid preventing bc/sc breaks when the client interface changes
+ IMPORT_C void RemoteAddr(TSockAddr& aAddr);
+ IMPORT_C TBool IsTransportRestartable() const;
+ IMPORT_C const TObexTransportInfo* TransportInfo() const;
+
+protected:
+ IMPORT_C CObexTransportControllerBase();
+
+private:
+ void BaseConstructL();
+
+private: // implemented by derived controller
+ virtual void DoRemoteAddr(TSockAddr& aAddr)=0;
+ virtual TBool DoIsTransportRestartable() const = 0;
+ virtual void NewTransportL(TObexConnectionInfo& aInfo) = 0;
+ virtual TUint16 GetReceivePacketDataLimit() = 0;
+
+protected: // from MObexTransportNotify
+ IMPORT_C virtual void DoProcess(CObexPacket &aPacket);
+ IMPORT_C virtual void DoError(TInt aError);
+ IMPORT_C virtual void DoTransportUp(TObexConnectionInfo& aInfo);
+ IMPORT_C virtual void DoSignalPacketProcessEvent(TObexPacketProcessEvent aEvent);
+
+protected: //Extension pattern
+ IMPORT_C virtual TAny* GetInterface(TUid aUid);
+
+private: // utility
+ void DeleteTransport();
+ void ConstructPacketsL();
+ void InitialiseTransportL(TObexConnectionInfo& aInfo);
+ void TransportUpError(TInt aError);
+
+protected: // owned
+ CObexConnector* iConnector;
+ CObexActiveRW* iActiveReader;
+ CObexActiveRW* iActiveWriter;
+ TObexConnectionInfo iConnectionInfo;
+ TObexTransportInfo* iTransportInfo;
+
+private: // unowned
+ MObexNotifyExtend* iOwner;
+
+private: // owned
+ CObexPacket* iReceivePacket;
+ CObexPacket* iSendPacket;
+ TAny* iFuture1;
+ // Instance identifier key
+ TUid iPrivateEComUID;
+ };
+
+#endif // __OBEXTRANSPORTCONTROLLERBASE_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/ObexReaderBase.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,243 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexreaderbase.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/mobextransportnotify.h>
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+/**
+*Constructor
+*/
+EXPORT_C CObexReaderBase::CObexReaderBase(TPriority aPriority,
+ MObexTransportNotify& aOwner,
+ TObexConnectionInfo& aInfo)
+ : CObexActiveRW (aPriority, aOwner, aInfo)
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+/**
+* Destructor
+*/
+EXPORT_C CObexReaderBase::~CObexReaderBase()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ Cancel();
+ }
+
+/**
+This function is a place holder for future use. If the iFuture1 variable is
+used it will need this function for any allocation required.
+
+To prevent binary compatiblity breaks if the iFuture1 variable is used, this
+function must be called from the
+NewL of derived classes.
+*/
+EXPORT_C void CObexReaderBase::BaseConstructL()
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+/**
+Start transfer. Calls into CObexActiveRW, which eventually queues a read
+
+@param aPacket The Obex packet to read into.
+*/
+EXPORT_C void CObexReaderBase::StartTransfer (CObexPacket& aPacket)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // Ensure that we don't try to queue two reads at once (this should probably
+ // never happen anyway).
+ if (IsActive())
+ {
+ FLOG(_L("\treturning because already active..."));
+ return;
+ }
+ iGotHeader = EFalse;
+ // Initial packet size indicates how much data we should ask for on the
+ // first read
+ // Packet & stream based transports do the same thing here due to ESOCK
+ // flexibility.
+ // See Remaining() and CompleteTransfer() for a clearer picture
+ iPacketSize = 0;
+ aPacket.Init(0);
+ NewRequest (aPacket);
+ }
+
+/**
+Check if the packet read is complete
+@return ETrue if the read is complete. EFalse otherwise.
+*/
+EXPORT_C TBool CObexReaderBase::CompleteTransfer ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iTransferError = KErrNone;
+
+ // Can't check anything until we have at least the OBEX packet header
+ if (iCount >= KObexPacketHeaderSize)
+ {// iCount is the number of bytes read thus far
+ if (!iGotHeader)
+ {
+ iPacketSize = iPacket->PacketSize ();
+
+ // Check packet's claimed size is at least as big as the header just sent
+ if ( iPacketSize < KObexPacketHeaderSize )
+ {
+ iTransferError = KErrCommsFrame;
+ return ETrue;
+ }
+ TInt maxPacketSize = GetMaxPacketSize();
+ LOG1(_L8("\taMaxPacketSize = %d"), maxPacketSize);
+ if (iPacketSize > maxPacketSize)
+ {// The peer is sending us a packet thats too large for us
+ iTransferError = KErrCommsFrame;
+ return (ETrue);
+ }
+ iGotHeader = ETrue;
+ OnReadActivity();
+ }
+
+
+ if (iCount >= iPacketSize)
+ {// We've got the whole packet.
+ return (ETrue);
+ }
+ }
+ return (EFalse);
+
+ }
+
+/**
+ Called when read activity is detected.
+ This method will certainly be called when read activity is
+ first detected on an Obex operation, and it may be called
+ from time to time thereafter until that Obex operation is
+ completed.
+*/
+EXPORT_C void CObexReaderBase::OnReadActivity()
+ {
+ iOwner.SignalPacketProcessEvent(EObexReadActivityDetected);
+ }
+
+/** Performs any actions necessary on completion of a read.
+*/
+EXPORT_C void CObexReaderBase::OnCompleteTransfer()
+ {
+ if(iTransferError)
+ {
+ iOwner.Error(iTransferError);
+ }
+ else
+ {
+ iOwner.Process(*iPacket);
+ }
+ }
+
+/*
+Returns the number of bytes remaining to be read based on the default packet
+size if the packet size is unknown, otherwise based on the packet size
+
+@return TInt the number of bytes remaining to be read
+*/
+EXPORT_C TInt CObexReaderBase::Remaining()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+
+ TInt remaining;
+
+ if (iPacketSize == 0)
+ {
+ // If we don't know the size of the packet yet, ask for as much as
+ // an initial or default size (-iCount) specifies
+ TInt defaultPacketSize = GetInitialPacketSize();
+ LOG1(_L8("\taRemainingLimit = %d"), defaultPacketSize);
+ remaining = defaultPacketSize - iCount;
+ }
+ else
+ {
+ remaining = iPacketSize - iCount;
+ }
+
+ if (remaining < 0)
+ {
+ remaining = 0;
+ }
+
+ return remaining;
+ }
+
+/**
+This function returns the buffer size of the read packet.
+
+@return TInt the size of the buffer held by the iPacket member variable
+*/
+EXPORT_C TInt CObexReaderBase::GetObexPacketBufferSize()
+ {
+ return iPacket->BufferSize();
+ }
+
+/**
+This function returns the size of the obex packet's header
+
+@return TInt the size of the obex header
+*/
+EXPORT_C TInt CObexReaderBase::GetObexPacketHeaderSize()
+ {
+ return KObexPacketHeaderSize;
+ }
+
+/**
+This function return the maximum limit the received data can be
+
+@return TInt the data limit of the obex packet
+*/
+EXPORT_C TInt CObexReaderBase::GetObexPacketDataLimit()
+ {
+ return iPacket->DataLimit();
+ }
+
+/**
+This function is part of the extension pattern and is implemented by all
+derived instantiable classes that need to extend it's interface.
+
+By default this returns null. Any derived class that is required to extend its
+interface and that of this base class returns its new interface in the form of
+an M class, that it extends, if and only if the corresponding TUid, aUid, is
+received. Otherwise the function calls the base class implementation,
+returning NULL.
+
+@return TAny* The M Class representing the extension to the interface
+otherwise NULL
+@param aUid The uid associated with the M Class that is being implemented
+*/
+EXPORT_C TAny* CObexReaderBase::GetInterface(TUid /*aUid*/)
+ {
+ return NULL;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/ObexTransportUtil.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,43 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "ObexTransportUtil.h"
+#include "logger.h"
+
+/**
+Function passed in as a parameter to TCleanupItem constructor to
+reset and destroy the received aPtr.
+
+@param aPtr a pointer to the object that is to be cleaned up
+*/
+void ResetAndDestroy(TAny* aPtr)
+ {
+ reinterpret_cast<RImplInfoPtrArray*>(aPtr)->ResetAndDestroy();
+ }
+
+/**
+Function that creates a clean up item for the received, aArray and
+specifies the cleanup function, ResetAndDestroy. When the item is
+removed from the cleanup stack the function, ResetAndDestroy will be
+called on aArray
+
+@param aArray the array to be pushed onto the cleanup stack
+*/
+void CleanupResetAndDestroyPushL(RImplInfoPtrArray& aArray)
+ {
+ TCleanupItem item(ResetAndDestroy, &aArray);
+ CleanupStack::PushL(item);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/ObexWriterBase.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,144 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexwriterbase.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/mobextransportnotify.h>
+#include "logger.h"
+#include "obextransportfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ObexWriterBase");
+#endif
+
+/**
+Constructor
+*/
+EXPORT_C CObexWriterBase::CObexWriterBase(TPriority aPriority,
+ MObexTransportNotify& aOwner,
+ TObexConnectionInfo& aInfo)
+ : CObexActiveRW (aPriority, aOwner, aInfo)
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+/**
+Destructor
+*/
+EXPORT_C CObexWriterBase::~CObexWriterBase()
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+/**
+This function is a placeholder for future use. If the iFuture1 variable is
+used it will need this function for any allocation required.
+
+To prevent binary compatiblity breaks if the iFuture1 variable is used, this
+function must be called from the NewL of derived classes.
+*/
+EXPORT_C void CObexWriterBase::BaseConstructL()
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+/**
+Start transfer. Calls into CObexActiveRW, which eventaully queues a write
+
+@param aPacket The Obex packet to write
+ */
+EXPORT_C void CObexWriterBase::StartTransfer (CObexPacket& aPacket)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iPacketSize = aPacket.PacketSize();
+ NewRequest(aPacket);
+
+ if(iPacket->IsFinal() &&
+ (iPacket->PacketProcessNotificationEvents() & EObexFinalPacketStarted))
+ {
+ iOwner.SignalPacketProcessEvent(EObexFinalPacketStarted);
+ }
+ }
+
+/**
+Returns true if the transfer has completed
+
+@return TBool return true if the transfer if complete otherwise return false
+*/
+EXPORT_C TBool CObexWriterBase::CompleteTransfer ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return (iCount >= iPacketSize);
+ }
+
+/** Performs any actions necessary on completion of a write.
+*/
+EXPORT_C void CObexWriterBase::OnCompleteTransfer()
+ {
+ iOwner.SignalPacketProcessEvent(EObexWriteCompleted);
+
+ if(iPacket->IsFinal() &&
+ (iPacket->PacketProcessNotificationEvents() & EObexFinalPacketFinished))
+ {
+ iOwner.SignalPacketProcessEvent(EObexFinalPacketFinished);
+ }
+
+ // Signal this after dereferences of iPacket because it might result in
+ // our destruction.
+ iOwner.SignalPacketProcessEvent(EObexWriteCompletedFinal);
+ }
+
+/**
+Return number of bytes remaining to be sent
+@return TInt number of bytes remaining to be sent
+*/
+EXPORT_C TInt CObexWriterBase::Remaining ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG (iPacketSize >= KObexPacketHeaderSize, PANIC(KPanicCat, EInvalidPacketSize));
+ return (iPacketSize - iCount);
+ }
+
+/**
+This function is part of the extension pattern and is implemented by all
+derived instantiable classes that need to extend its interface.
+
+By default this returns null. Any derived class that is required to extend its
+interface and that of this base class returns its new interface in the form of
+an M class, that it extends, if and only if the corresponding TUid, aUid, is
+received. Otherwise the function calls the base class implementation,
+returning NULL.
+
+@return TAny* The M Class representing the extension to the interface
+otherwise NULL
+@param aUid The uid associated with the M Class that is being implemented
+*/
+EXPORT_C TAny* CObexWriterBase::GetInterface(TUid /*aUid*/)
+ {
+ return NULL;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/logengine.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,355 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+
+#include <e32base.h>
+#include <comms-infras/commsdebugutility.h>
+#include "logger.h"
+
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KSubsystem, "obex");
+_LIT8(KLogCmpt, "logengine");
+#endif
+
+
+NONSHARABLE_CLASS(TLogData)
+ {
+ public:
+#ifdef __FLOG_ACTIVE
+ TLogData();
+
+ void SetLogTags(const TDesC8& aCmpt);
+
+ TInt iAccessCount;
+
+ RFileLogger iLogEngine;
+ TBuf8<KMaxTagLength> iCurrentComponent;
+#endif
+ };
+
+
+#ifdef __FLOG_ACTIVE
+TLogData::TLogData()
+ : iAccessCount(0), iCurrentComponent(KNullDesC8)
+ {}
+
+void TLogData::SetLogTags(const TDesC8& aCmpt)
+ {
+ if (aCmpt != iCurrentComponent)
+ {
+ iLogEngine.SetLogTags(KSubsystem, aCmpt.Left(KMaxTagLength));
+ iCurrentComponent = aCmpt.Left(KMaxTagLength);
+ }
+ }
+#endif
+
+#define GETLOG TLogData* __logger = static_cast<TLogData*>(Dll::Tls());
+
+
+
+EXPORT_C /*static*/ TInt CObexLog::Connect()
+ {
+#ifdef __FLOG_ACTIVE
+ GETLOG;
+
+ if (!__logger)
+ {
+ CObexLog::Write(KLogCmpt, _L8("Opening new logger connection"));
+ __logger = new TLogData();
+ if (!__logger)
+ {
+ CObexLog::Write(KLogCmpt, _L8("Opening logger connection failed, no memory"));
+ return KErrNoMemory;
+ }
+
+ __logger->iLogEngine.Connect();
+ Dll::SetTls(__logger);
+ }
+
+ __logger->iAccessCount++;
+ CObexLog::WriteFormat(KLogCmpt, _L8("Opening -- %d instances now open"), __logger->iAccessCount);
+
+ return KErrNone;
+#else
+ return KErrNotSupported;
+#endif
+ }
+
+
+EXPORT_C /*static*/ void CObexLog::Close()
+ {
+#ifdef __FLOG_ACTIVE
+ GETLOG;
+
+ if (__logger)
+ {
+ TInt& count = __logger->iAccessCount;
+
+ if (count)
+ {
+ count--;
+ CObexLog::WriteFormat(KLogCmpt, _L8("Closing -- %d instance(s) left open"), count);
+ if (!count)
+ {
+ __logger->iLogEngine.Close();
+ delete __logger;
+ Dll::SetTls(NULL);
+ CObexLog::Write(KLogCmpt, _L8("Fully closed and deleted, now flogging statically."));
+ }
+ }
+ else
+ {
+ CObexLog::Write(KLogCmpt, _L8("Not closing -- not opened"));
+ }
+ }
+#endif
+ }
+
+
+
+EXPORT_C /*static*/ void CObexLog::Write(const TDesC8& IF_FLOGGING(aCmpt), const TDesC8& IF_FLOGGING(aText))
+ {
+#ifdef __FLOG_ACTIVE
+ GETLOG;
+
+ if (__logger)
+ {
+ __logger->SetLogTags(aCmpt);
+ __logger->iLogEngine.Write(aText);
+ }
+ else
+ {
+ RFileLogger::Write(KSubsystem, aCmpt, aText);
+ }
+#endif
+ }
+
+
+EXPORT_C /*static*/ void CObexLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC8> IF_FLOGGING(aFmt), ...)
+ {
+#ifdef __FLOG_ACTIVE
+ VA_LIST list;
+ VA_START(list, aFmt);
+
+ GETLOG;
+
+ if (__logger)
+ {
+ __logger->SetLogTags(aCmpt);
+ __logger->iLogEngine.WriteFormat(aFmt, list);
+ }
+ else
+ {
+ RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, list);
+ }
+#endif
+ }
+
+
+EXPORT_C /*static*/ void CObexLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC8> IF_FLOGGING(aFmt), VA_LIST& IF_FLOGGING(aList))
+ {
+#ifdef __FLOG_ACTIVE
+ GETLOG;
+
+ if (__logger)
+ {
+ __logger->SetLogTags(aCmpt);
+ __logger->iLogEngine.WriteFormat(aFmt, aList);
+ }
+ else
+ {
+ RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, aList);
+ }
+#endif
+ }
+
+
+EXPORT_C /*static*/ void CObexLog::Write(const TDesC8& IF_FLOGGING(aCmpt), const TDesC16& IF_FLOGGING(aText))
+ {
+#ifdef __FLOG_ACTIVE
+ GETLOG;
+
+ if (__logger)
+ {
+ __logger->SetLogTags(aCmpt);
+ __logger->iLogEngine.Write(aText);
+ }
+ else
+ {
+ RFileLogger::WriteFormat(KSubsystem, aCmpt, aText);
+ }
+#endif
+ }
+
+
+EXPORT_C /*static*/ void CObexLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC16> IF_FLOGGING(aFmt), ...)
+ {
+#ifdef __FLOG_ACTIVE
+ VA_LIST list;
+ VA_START(list, aFmt);
+
+ GETLOG;
+
+ if (__logger)
+ {
+ __logger->SetLogTags(aCmpt);
+ __logger->iLogEngine.WriteFormat(aFmt, list);
+ }
+ else
+ {
+ RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, list);
+ }
+#endif
+ }
+
+
+EXPORT_C /*static*/ void CObexLog::WriteFormat(const TDesC8& IF_FLOGGING(aCmpt), TRefByValue<const TDesC16> IF_FLOGGING(aFmt), VA_LIST& IF_FLOGGING(aList))
+ {
+#ifdef __FLOG_ACTIVE
+ GETLOG;
+
+ if (__logger)
+ {
+ __logger->SetLogTags(aCmpt);
+ __logger->iLogEngine.WriteFormat(aFmt, aList);
+ }
+ else
+ {
+ RFileLogger::WriteFormat(KSubsystem, aCmpt, aFmt, aList);
+ }
+#endif
+ }
+
+
+EXPORT_C /*static*/ void CObexLog::HexDump(const TDesC8& IF_FLOGGING(aCmpt), const TText* IF_FLOGGING(aHeader), const TText* IF_FLOGGING(aMargin), const TUint8* IF_FLOGGING(aPtr), TInt IF_FLOGGING(aLen))
+ {
+#ifdef __FLOG_ACTIVE
+ GETLOG;
+
+ if (__logger)
+ {
+ __logger->SetLogTags(aCmpt);
+ __logger->iLogEngine.HexDump(aHeader, aMargin, aPtr, aLen);
+ }
+ else
+ {
+ RFileLogger::HexDump(KSubsystem, aCmpt, TPtrC8(aPtr, aLen), KNullDesC8);
+ }
+#endif
+ }
+
+
+
+
+
+
+
+/**
+Leave (if error) verbosely- log name of file and line number just before
+leaving.
+@param aFile The file we're leaving from.
+@param aLine The line number we're leaving from.
+@param aReason The leave code.
+*/
+EXPORT_C void VerboseLeaveIfErrorL(const TDesC8& IF_FLOGGING(aCpt),
+ char* IF_FLOGGING(aFile),
+ TInt IF_FLOGGING(aLine),
+ TInt IF_FLOGGING(aReason))
+ {
+#ifdef __FLOG_ACTIVE
+ // only leave if an error value
+ if ( aReason >= KErrNone )
+ {
+ return;
+ }
+
+ _LIT8(KLeavePrefix, "LEAVE: ");
+
+ TPtrC8 fullFileName((const TUint8*)aFile);
+ TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+
+ TBuf8<256> buf;
+ buf.Append(KLeavePrefix);
+ buf.AppendFormat(_L8("aReason = %d [file %S, line %d]"), aReason, &fileName,
+ aLine);
+ CObexLog::Write(aCpt, buf);
+
+ // finally
+ User::Leave(aReason);
+#endif
+ }
+
+/**
+Panic verbosely- log name of file and line number just before panicking.
+@param aFile The file that's panicking.
+@param aLine The line number that's panicking.
+@param aReason The panic code.
+@param aPanicName The text of the panic code.
+@param aPanicCategory The panic category.
+*/
+EXPORT_C void VerbosePanic(const TDesC8& IF_FLOGGING(aCpt),
+ char* IF_FLOGGING(aFile),
+ TInt IF_FLOGGING(aLine),
+ TInt IF_FLOGGING(aPanicCode),
+ TText8* IF_FLOGGING(aPanicName),
+ const TDesC& IF_FLOGGING(aPanicCategory))
+ {
+#ifdef __FLOG_ACTIVE
+ _LIT8(KPanicPrefix, "PANIC: code ");
+
+ TPtrC8 fullFileName((const TUint8*)aFile);
+ TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+
+ TBuf8<256> buf;
+ buf.Append(KPanicPrefix);
+ buf.AppendFormat(_L8("%d = %s [file %S, line %d]"),
+ aPanicCode,
+ aPanicName,
+ &fileName,
+ aLine);
+ CObexLog::Write(aCpt, buf);
+
+ // finally
+ User::Panic(aPanicCategory, aPanicCode);
+#endif
+ }
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KInstrumentIn, ">>%S this = [0x%08x]");
+_LIT8(KInstrumentOut, "<<%S");
+#endif
+
+EXPORT_C TFunctionLogger::TFunctionLogger(const TDesC8& IF_FLOGGING(aCpt), const TDesC8& IF_FLOGGING(aString), TAny* IF_FLOGGING(aThis))
+ {
+#ifdef __FLOG_ACTIVE
+ iCpt.Set(aCpt);
+ iString.Set(aString);
+ CObexLog::WriteFormat(iCpt, KInstrumentIn, &iString, aThis);
+#endif
+ }
+
+EXPORT_C TFunctionLogger::~TFunctionLogger()
+ {
+#ifdef __FLOG_ACTIVE
+ CObexLog::WriteFormat(iCpt, KInstrumentOut, &iString);
+#endif
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/mobextransportnotify.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,66 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/mobextransportnotify.h>
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+/**
+Process the received packet.
+@param aPacket An obex packet.
+*/
+EXPORT_C void MObexTransportNotify::Process(CObexPacket &aPacket)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ DoProcess(aPacket);
+ }
+
+/**
+Indicate that an error has occurred in the transport.
+@param aError The error that has occurred.
+*/
+EXPORT_C void MObexTransportNotify::Error(TInt aError)
+ {
+ LOG_LINE
+ LOG_FUNC
+ LOG1(_L8("\taError = %d"), aError);
+
+ DoError(aError);
+ }
+
+/**
+Indicate that the transport is up.
+@param aInfo The connection info.
+*/
+EXPORT_C void MObexTransportNotify::TransportUp(TObexConnectionInfo& aInfo)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ DoTransportUp(aInfo);
+ }
+
+/** Signals that an event related to processing the packet has occurred.
+@param aEvent The event that has occurred.
+*/
+EXPORT_C void MObexTransportNotify::SignalPacketProcessEvent(TObexPacketProcessEvent aEvent)
+ {
+ DoSignalPacketProcessEvent(aEvent);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexactivereader.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,113 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexactivereader.h>
+#include <es_sock.h>
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+/**
+Factory function.
+@param aOwner the owner of this
+@param aSocket a socket for reading and writing
+@param aInfo connection information
+@return Ownership of a new active reader.
+*/
+EXPORT_C CObexActiveReader* CObexActiveReader::NewL(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo)
+ {
+ CObexActiveReader* self = new(ELeave) CObexActiveReader(aOwner, aSocket, aInfo);
+ CleanupStack::PushL(self);
+ self->BaseConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+Constructor
+@param aOwner the owner of this
+@param aSocket a socket for reading and writing
+@param aInfo connection information
+*/
+CObexActiveReader::CObexActiveReader (MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo)
+ : CObexReaderBase (EPriorityStandard, aOwner, aInfo),
+ iSocket(aSocket)
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+/**
+Destructor
+*/
+EXPORT_C CObexActiveReader::~CObexActiveReader ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ Cancel ();
+ }
+
+/**
+Called to actually transfer some data into iLocation
+*/
+void CObexActiveReader::DoTransfer ()
+ {
+ LOG_FUNC
+
+ iSocket.Recv(iLocation, KSockReadContinuation, iStatus);
+ SetActive ();
+ }
+
+/**
+Return the maximum packet size
+@return TInt the maximum packet size for this transport
+*/
+TInt CObexActiveReader::GetMaxPacketSize()
+ {
+ LOG_FUNC
+
+ // Some slightly dubious logic here...
+ // IrDA has a degenerate case when running over a 256 byte transport layer link, we claim
+ // to support <255 bytes. The Obex spec says that all stations must be able to handle
+ // 255 bytes, so some stacks may ignore our limit.
+ // Thus we compare against the actual buffer size, rather than what we told the remote end
+ // we could handle, so we *may* be able to handle being sent a few bytes more than expected...
+
+ TInt ret = GetObexPacketBufferSize();
+ LOG1(_L8("\tret = %d"), ret);
+ return ret;
+ }
+
+/**
+Returns a initial packet size when the packet size of iPacket is not know. This is used
+when determining the remaining bytes to be read.
+@return TInt the initial packet size
+*/
+TInt CObexActiveReader::GetInitialPacketSize ()
+ {
+ LOG_FUNC
+
+ return GetObexPacketHeaderSize();
+ }
+
+void CObexActiveReader::DoCancel ()
+ {
+ LOG_FUNC
+
+ iSocket.CancelRecv ();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexactiverw.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,139 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexactiverw.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/transport/mobextransportnotify.h>
+#include <obex/transport/obexconnector.h>
+#include "ObexTransportUtil.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+/**
+Constructor
+
+@param aPriority a priority
+@param aOwner the owner
+@param aInfo connection information
+*/
+CObexActiveRW::CObexActiveRW(TPriority aPriority,
+ MObexTransportNotify& aOwner,
+ TObexConnectionInfo& aInfo)
+ : CActive (aPriority),
+ iOwner(aOwner),
+ iLocation (NULL, 0)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ CActiveScheduler::Add (this);
+ iPacketBased = aInfo.iSocketType==TObexConnectionInfo::ESocketPacket ? ETrue : EFalse;
+ }
+
+/**
+Destructor
+*/
+CObexActiveRW::~CObexActiveRW()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ Cancel();
+ }
+
+/**
+Start a new write or read
+Reset the pointer descriptor to the start of the buffer and make the call to
+start the transfer
+
+@param aPacket the obex packet to read or write
+*/
+void CObexActiveRW::NewRequest(CObexPacket& aPacket)
+ {
+ LOG_FUNC
+
+ iPacket = &aPacket;
+ iCount = 0;
+ // Set descriptor to start of buffer
+ // Size pointer according to either the number of bytes remaining in packet
+ // OR maximum number of bytes we can receive (see Remaining())
+ iLocation.Set(iPacket->iBuffer, 0, Remaining ());
+ DoTransfer();
+ }
+
+/*
+Non-virtual method calling virtual method StartTransfer. BC protection.
+
+@param aPacket the obex packet to transfer
+*/
+void CObexActiveRW::Transfer(CObexPacket& aPacket)
+ {
+ LOG_FUNC
+
+ StartTransfer(aPacket);
+ }
+
+/**
+RunL called after a read/write has completed
+Check to see if we need to issue another request, otherwise process the
+complete packet
+*/
+EXPORT_C void CObexActiveRW::RunL()
+ {
+ LOG_LINE
+ LOG_FUNC
+ LOG1(_L8("\tiStatus = %d"), iStatus.Int());
+
+/*
+ TBuf<256> hexBuf;
+ FTRACE(FPrint(_L("CObexActiveRW::RunL iLocation.Length() = %d"), iLocation.Length()));
+ for (TInt i = 0; i < iLocation.Length(); i++)
+ {
+ hexBuf.AppendFormat(_L("%02X "), iLocation[i]);
+ if ((i % 16) == 15)
+ {
+ FLOG(hexBuf);
+ hexBuf = KNullDesC;
+ }
+ }
+ FLOG(hexBuf);
+*/
+
+ // Check the request completed OK
+ if ( iStatus != KErrNone )
+ {
+ iOwner.Error(iStatus.Int());
+ return;
+ }
+
+ // Update the byte count and check to see if the transfer is complete
+ iCount += iLocation.Size();
+ if ( CompleteTransfer() )
+ {
+ // Inform interested parties
+ OnCompleteTransfer();
+ return;
+ }
+ // Otherwise update the buffer pointer and start another transfer
+ LOG1(_L8("CObexActiveRW::RunL Setting location, remaining=%d"), Remaining());
+ iLocation.Set (&iPacket->iBuffer[iCount], 0, Remaining());
+ if ( iLocation.MaxLength() > 0 )
+ {
+ DoTransfer();
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexactivewriter.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,95 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexactivewriter.h>
+#include <obex/internal/obexpacket.h>
+#include <es_sock.h>
+#include <obex/transport/mobextransportnotify.h>
+#include "ObexTransportUtil.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+EXPORT_C CObexActiveWriter* CObexActiveWriter::NewL(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo)
+ {
+ CObexActiveWriter* self = new(ELeave) CObexActiveWriter(aOwner, aSocket, aInfo);
+ CleanupStack::PushL(self);
+ self->BaseConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CObexActiveWriter::CObexActiveWriter (MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo)
+ : CObexWriterBase (EPriorityHigh, aOwner, aInfo),
+ iInfo ( aInfo ),
+ iSocket(aSocket)
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+EXPORT_C CObexActiveWriter::~CObexActiveWriter ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ Cancel ();
+ }
+
+/**
+Start transfer.
+Calls into CObexActiveRW, which eventaully queues a write which is limited by
+the smaller of iInfo's max send size and aPacket's data limit
+
+@param aPacket The Obex packet to write
+*/
+void CObexActiveWriter::StartTransfer (CObexPacket& aPacket)
+ {
+ LOG_FUNC
+
+ // Find out how much we can write to the remote end per transfer
+ iTransportWriteLimit = Min(iInfo.iMaxSendSize, aPacket.DataLimit());
+ LOG1(_L8("\tiTransportWriteLimit = %d"), iTransportWriteLimit);
+ CObexWriterBase::StartTransfer(aPacket);
+ }
+
+
+// Called to actually transfer some data out from iLocation
+void CObexActiveWriter::DoTransfer ()
+ {
+ LOG_FUNC
+
+ // Send the biggest chunk we can over the transport
+ if (iPacketBased && (iLocation.MaxLength () > iTransportWriteLimit))
+ {
+ iLocation.SetLength (iTransportWriteLimit);
+ }
+ else
+ {
+ iLocation.SetMax ();
+ }
+
+ iSocket.Write (iLocation, iStatus);
+ SetActive ();
+ }
+
+void CObexActiveWriter::DoCancel ()
+ {
+ LOG_FUNC
+
+ iSocket.CancelSend ();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexconnectdata.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,49 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include "obexconnectdata.h"
+
+TObexConnectData::TObexConnectData ()
+ {
+ iVersion = 0;
+ iFlags = 0x00;
+ iMaxPacketLength = 0x0000;
+ }
+
+TUint16 TObexConnectData::DoTotalSize () const
+ {
+ return (4);
+ }
+
+TUint16 TObexConnectData::ParseIn (TUint8* aSource, const TUint16 aMaxSize)
+ {
+ if (aMaxSize < TotalSize ())
+ return (0);
+ iVersion = aSource[0];
+ iFlags = aSource[1];
+ iMaxPacketLength = BigEndian::Get16 (&aSource[2]);
+ return (TotalSize ());
+ }
+
+TUint16 TObexConnectData::WriteOut (TUint8* aDest, const TUint16 aMaxSize) const
+ {
+ if (aMaxSize < TotalSize ())
+ return (0);
+ aDest[0] = iVersion;
+ aDest[1] = iFlags;
+ BigEndian::Put16 (&aDest[2], iMaxPacketLength);
+ return (TotalSize ());
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexconnector.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,78 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexconnector.h>
+
+/**
+This function is a placeholder for future use. If iFuture1 variable is
+used it will need this function for any allocation required.
+
+To prevent binary compatibility breaks if the iFuture1 variable is used,
+this function must be called from the NewL of derived classes.
+*/
+EXPORT_C void CObexConnector::BaseConstructL()
+ {
+ }
+
+/**
+This function is part of the extension pattern and must be implemented by
+all derived instantiable classes.
+By default this returns null. Any derived class that is required to
+extend its interface and that of this base class returns its new interface
+in the form of an M class, that it extends, if and only if the
+corresponding TUid, aUid, is received. Otherwise the function calls the
+base class implementation, returning NULL.
+
+@return TAny* The M Class representing the extension to the interface
+otherwise NULL
+@param aUid The uid associated with the M Class that is being implemented
+@publishedPartner
+@released
+*/
+EXPORT_C TAny* CObexConnector::GetInterface(TUid /*aUid*/)
+ {
+ return NULL;
+ }
+
+/** Constructor.
+@param aObserver The MObexTransportNotify object to notify of
+transport-related events. This object will typically be the concrete
+CObexTransportControllerBase.
+*/
+EXPORT_C CObexConnector::CObexConnector(MObexTransportNotify& aObserver)
+: iObserver(aObserver)
+ {
+ }
+
+/**
+Destructor.
+Currently does no work (NB BaseConstructL currently does no work either). If
+BaseConstructL ever allocates memory into iFuture1, we'll need to free it
+here. But by then licensee connectors' vtables will already have been
+built, *pointing at CBase's destructor*. We need this destructor here so
+that iFuture1, if it's ever allocated, will be freed correctly.
+*/
+EXPORT_C CObexConnector::~CObexConnector()
+ {
+ }
+
+/** Accessor for the observer (an MObexTransportNotify).
+@return The MObexTransportNotify to notify of transport-related events.
+*/
+EXPORT_C MObexTransportNotify& CObexConnector::Observer()
+ {
+ return iObserver;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexdata.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,21 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexdata.h>
+
+EXPORT_C TUint16 TObexData::TotalSize () const
+ {
+ return DoTotalSize();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexinternalheader.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,463 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexinternalheader.h>
+#include <es_sock.h>
+#include "logger.h"
+#include "obextransportfaults.h"
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ObexIntHdr");
+#endif
+
+/** @internalComponent */
+const TUint8 KObexHeaderTypeMask = 0xc0;
+
+/**
+Constructor
+*/
+EXPORT_C TObexInternalHeader::TObexInternalHeader ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHVSize = 0;
+ }
+
+/**
+Try to read a header from aSource, taking up to a maximum of aMaxSize bytes.
+Returns the number of bytes actually read out.
+*/
+TUint16 TObexInternalHeader::ParseIn (TUint8* aSource, const TUint16 aMaxSize)
+ {
+ iHVSize = 1;
+ if (aMaxSize < KObexHeaderHIShortSize + 1) return (0);
+ SetHI (STATIC_CAST(THeaderID, *aSource));
+
+ switch (HIType ())
+ {
+ case EUnicode:
+ case EByteSeq:
+ if (aMaxSize < KObexHeaderHILongSize) return (0);
+ {
+ TInt hvsize = BigEndian::Get16 (&aSource[1]) - HISize ();
+ if (hvsize < 0) return (0);
+ iHVSize = STATIC_CAST(TUint16, hvsize);
+ }
+ iHV.iObex = &aSource[KObexHeaderHILongSize];
+ iHVRep = EHVObexDefault;
+ break;
+ case E4Byte:
+ iHVSize = 4; //fallthrough to case E1Byte
+ case E1Byte:
+ iHV.iObex = &aSource[KObexHeaderHIShortSize];
+ iHVRep = EHVObexDefault;
+ break;
+ default:
+ return (0);
+ }
+ if (aMaxSize < TotalSize ())
+ return (0);
+ return (TotalSize ());
+ }
+
+/**
+Write this header out to aDest, writting up to a max of aMaxSize bytes.
+returns the number of bytes actually written.
+All complicated by the fact that the internal rep. of the data in the header
+might be in one of a number of forms, as well as having to convert to the
+correct OBEX form, all with heavy consideration for thick and thin builds.
+For unicode on the wire, we also need to to endian conversion too....
+*/
+TUint16 TObexInternalHeader::WriteOut (TUint8* aDest, const TUint16 aMaxSize) const
+ {
+ TInt byteswritten = TotalSize ();
+ if (aMaxSize < byteswritten) return (0);
+ *aDest = iHI;
+
+ switch (HIType ())
+ {
+ case EUnicode:
+ case EByteSeq:
+ // The following is arranged in order of expected frequency of use.
+ // The less common the conversion, the less effort is put to efficiency.
+ if (iHVRep == EHVDefered)
+ {// The data will actually be written after the header is inserted.
+ byteswritten = iHVMaxSize + KObexHeaderHILongSize;
+ if (byteswritten > aMaxSize)
+ byteswritten = aMaxSize;
+ iHV.iDefered->Set (&aDest[KObexHeaderHILongSize], 0, byteswritten - KObexHeaderHILongSize);
+ }
+ else if (iHVRep == EHVObexDefault)
+ {// The easy case: just send the data directly
+ Mem::Copy (&aDest[KObexHeaderHILongSize], iHV.iObex, iHVSize);
+ }
+ else
+ {// Big time (Uniocde/Ascii) conversions necessary
+ TBufC<40> numbuf;
+ TPtr src (numbuf.Des ());
+ if (iHVRep == EHVInt)
+ {
+ if ( GetHVText(src) != KErrNone )
+ {
+ return (0);
+ }
+ }
+ else
+ {
+ src.Set (iHV.iMachine, iHVSize / sizeof (TText), iHVSize / sizeof (TText));
+ }
+ TInt i;
+ if (HIType () == EUnicode)
+ {// Need to convert to Unicode, from internal machine rep
+ byteswritten = KObexHeaderHILongSize;
+ if(src.Length())
+ {// Only need null term if the length is non-zero
+ byteswritten += (2 * (src.Length () + 1));
+ // 2 = Unicode word size, + 1 for null terminal
+ if (aMaxSize < byteswritten) return (0);
+ for (i = 0; i < src.Length (); ++i)
+ BigEndian::Put16 (&aDest[KObexHeaderHILongSize + (i * 2)], src[i]);
+ BigEndian::Put16 (&aDest[KObexHeaderHILongSize + (i * 2)], 0); // Null term
+ }
+ }
+ else // HIType == ByteSeq
+ {// Convert to obex "byte sequence", from internal machine rep.
+ byteswritten = KObexHeaderHILongSize + src.Length ();
+ if (aMaxSize < byteswritten) return (0);
+ for (i = 0; i < src.Length (); ++i)
+ aDest[KObexHeaderHILongSize + i] = STATIC_CAST(TUint8, src[i]);
+ }
+ }
+ BigEndian::Put16 (&aDest[1], STATIC_CAST(TUint16, byteswritten));
+ break;
+ case E1Byte:
+ aDest[KObexHeaderHIShortSize] = STATIC_CAST(TUint8, HVInt ());
+ break;
+ case E4Byte:
+ BigEndian::Put32 (&aDest[KObexHeaderHIShortSize], HVInt ());
+ break;
+ default:
+ return (0);
+ }
+ return (STATIC_CAST(TUint16, byteswritten));
+ }
+
+/**
+Setter for the header id
+
+@param aHID Header id
+*/
+EXPORT_C void TObexInternalHeader::SetHI (THeaderID aHID)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iHI = aHID;
+ }
+
+/**
+Setter for the header id and header value
+
+@param aHID Header id
+@param aValue Value for the header
+@see SetHI
+*/
+EXPORT_C void TObexInternalHeader::Set (THeaderID aHID, TInt aValue)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ SetHI (aHID);
+ iHV.iInt = aValue;
+ iHVRep = EHVInt;
+ }
+
+/**
+Setter for the header id, header value and size of the header value
+
+@param aHID Header id
+@param aHV Header value
+@param aHVSize Size of the header value
+@see SetHI
+*/
+EXPORT_C void TObexInternalHeader::Set (THeaderID aHID, TUint8* aHV, TInt aHVSize)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG (aHV, PANIC (KPanicCat, ETransportNullPointer));
+ __ASSERT_DEBUG (aHVSize >= 0, PANIC (KPanicCat, EInvalidHeaderSize));
+ __ASSERT_DEBUG (aHVSize < (TInt)(KMaxTUint16 - 3), PANIC (KPanicCat, EInvalidHeaderSize));
+ SetHI (aHID);
+ iHV.iObex = aHV;
+ iHVSize = STATIC_CAST(TUint16, aHVSize);
+ iHVRep = EHVObexDefault;
+ }
+
+/**
+Setter for the header id, header value and size of the header value
+
+@param aHID Header id
+@param aString Descriptor containing the header value and its size
+@see SetHI
+*/
+EXPORT_C void TObexInternalHeader::Set (THeaderID aHID, const TDesC& aString)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG (aString.Size () <= (TInt)(KMaxTUint16 - 3), PANIC(KPanicCat, EStringOverflow));
+ SetHI (aHID);
+ iHV.iMachine = CONST_CAST(TText*, aString.Ptr ());
+ iHVSize = STATIC_CAST(TUint16, aString.Size ());
+ iHVRep = EHVMachineText;
+ }
+
+/**
+Setter for the header id, the header value data inserter, min and max size
+
+@param aHID Header id
+@param aDataInserter Data inserter
+@param aMinSize Min size of header value
+@param aMaxSize Max size of header value
+@see SetHI
+*/
+EXPORT_C void TObexInternalHeader::SetDeferred (THeaderID aHID, TPtr8* aDataInserter, TInt aMinSize, TInt aMaxSize)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG (aMinSize > 0, PANIC(KPanicCat, EInvalidHeaderSize));
+ SetHI (aHID);
+ iHV.iDefered = aDataInserter;
+ iHVSize = STATIC_CAST (TUint16, aMinSize);
+ if (aMaxSize > TInt(KMaxTUint16 - KObexHeaderHILongSize))
+ iHVMaxSize = TUint16(KMaxTUint16 - (TUint)(KObexHeaderHILongSize));
+ else
+ iHVMaxSize = STATIC_CAST (TUint16, aMaxSize > aMinSize ? aMaxSize : aMinSize);
+ iHVRep = EHVDefered;
+ aDataInserter->Set (NULL, 0, 0);
+ }
+
+/**
+Returns the internal header ID
+
+@return Internal header ID
+*/
+EXPORT_C TObexInternalHeader::THeaderID TObexInternalHeader::HI () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return (iHI);
+ }
+
+/**
+Returns the internal header type
+
+@return Internal header type
+*/
+EXPORT_C TObexInternalHeader::THeaderType TObexInternalHeader::HIType () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return (STATIC_CAST(THeaderType, (HI () & KObexHeaderTypeMask)));
+ }
+
+/**
+Returns the internal header value
+
+@return Internal header value
+*/
+EXPORT_C TInt TObexInternalHeader::HVInt () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iHVRep == EHVObexDefault)
+ {
+ if (HIType () == E4Byte)
+ return (BigEndian::Get32 (iHV.iObex));
+ else
+ return (*iHV.iObex);
+ }
+ if (iHVRep == EHVInt)
+ return (iHV.iInt);
+ // Don't bother converting machine strings to ints!
+ return (0);
+ }
+
+/**
+Returns a pointer to the internal header value byte sequence
+
+@return Pointer to the internal header value byte sequence
+*/
+EXPORT_C TUint8* TObexInternalHeader::HVByteSeq () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iHVRep == EHVObexDefault)
+ return (iHV.iObex);
+ // Could do alsorts of fancy stuff else.
+ return (NULL);
+ }
+
+/**
+Returns header value as text
+
+Take the HV and put "an appropriate" representation of it into aString.
+The stable mate of "WriteOut" in terms of nasty conversions, but again all
+necessary in order to support both thick & thin builds.
+
+@return Error code
+*/
+EXPORT_C TInt TObexInternalHeader::GetHVText (TDes& aString) const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ switch (iHVRep)
+ {
+ case EHVMachineText:
+ FLOG(_L8("EHVMachineText"));
+ if (aString.Length () < STATIC_CAST(TInt, TUint(iHVSize / sizeof(TText))))
+ {
+ FLOG(_L8("Target descriptor too small"));
+ return (KErrBadDescriptor);
+ }
+
+ aString.Copy (TPtr (iHV.iMachine, iHVSize / sizeof(TText), iHVSize / sizeof(TText)));
+ return (KErrNone);
+
+ case EHVObexDefault:
+ FLOG(_L8("EHVObexDefault"));
+ if (HIType () == EUnicode)
+ {
+ // Unicode: read big endian and shove into descriptor
+ FLOG(_L8(" -Unicode"));
+ if (aString.MaxLength () < iHVSize / 2)
+ {
+ FLOG(_L8("Target descriptor too small"));
+ return (KErrBadDescriptor);
+ }
+
+ aString.SetLength (iHVSize / 2);
+ TInt i;
+ for (i = 0; i < iHVSize / 2; ++i)
+ {
+ aString[i] = STATIC_CAST (TText, BigEndian::Get16 (&iHV.iObex[i * 2]));
+ }
+
+ if (i > 0 && aString[--i] == 0) // Zero length headers have no null terminal!
+ {
+ // Make sure last char is null term, and chop it off
+ aString.SetLength (i);
+ }
+
+ return (KErrNone);
+ }
+
+ if (HIType () == EByteSeq)
+ {
+ // Descriptors can actually do the conversion for us here.
+ FLOG(_L8(" -ByteSeq"));
+ if (aString.MaxLength () < iHVSize)
+ {
+ FLOG(_L8("Target descriptor too small"));
+ return (KErrBadDescriptor);
+ }
+
+ aString.Copy (TPtrC8 (iHV.iObex, iHVSize));
+ return (KErrNone);
+ }
+ break;
+
+ case EHVInt:
+ FLOG(_L8("EHVInt"));
+ aString.Num (HVInt ());
+ return (KErrNone);
+
+ default:
+ break;
+ }
+
+ FLOG(_L8("Unknown error..."));
+ aString.SetLength (0);
+ return (KErrGeneral);
+ }
+
+ TUint16 TObexInternalHeader::DoTotalSize () const
+ {
+ return (STATIC_CAST(TUint16, HISize () + HVSize ()));
+ }
+
+/**
+Returns the size of the internal header
+
+@return Size of the internal header
+*/
+EXPORT_C TUint16 TObexInternalHeader::HISize () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ switch (HIType ())
+ {
+ case EUnicode:
+ case EByteSeq:
+ return (KObexHeaderHILongSize);
+ case E1Byte:
+ case E4Byte:
+ return (KObexHeaderHIShortSize);
+ default:
+ return (0);
+ }
+ }
+
+/**
+Returns the size of the internal header value
+
+@return Size of the internal header value
+*/
+EXPORT_C TUint16 TObexInternalHeader::HVSize () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iHVRep == EHVObexDefault || iHVRep == EHVDefered)
+ return (iHVSize);
+ TInt fact = 1;
+ switch (HIType ())
+ {
+ case EUnicode:
+ fact = 2; //fallthrough to case EByteSeq
+ case EByteSeq:
+ if (iHVRep == EHVMachineText)
+ return (STATIC_CAST(TUint16, fact * iHVSize / sizeof (TText)));
+ return (40);
+ case E1Byte:
+ return (1);
+ case E4Byte:
+ return (4);
+ default:
+ return (0);
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obexpacket.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,334 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <es_sock.h>
+#include <obex/internal/obexpacket.h>
+#include <obex/internal/obexinternalconstants.h>
+#include <obex/internal/obexdata.h>
+#include "logger.h"
+#include "obextransportfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+_LIT(KPanicCat, "ObexPacket");
+CObexPacket::CObexPacket (TUint16 aBufferSize, TUint16 aDataLimit) : iBufferSize ( aBufferSize ), iDataLimit ( aDataLimit )
+ {
+ LOG_FUNC
+ }
+
+/**
+Destructor
+*/
+EXPORT_C CObexPacket::~CObexPacket ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ delete[] iBuffer;
+ }
+
+/**
+*/
+EXPORT_C CObexPacket* CObexPacket::NewL (TUint16 aBufferSize, TUint16 aDataLimit)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+ LOG2(_L8("\taBufferSize = %d, aDataLimit = %d"), aBufferSize, aDataLimit);
+
+ // Data limit can't be larger than the buffer
+ __ASSERT_ALWAYS ( aBufferSize >= aDataLimit, PANIC(KPanicCat, EDataLimitLargerThanBuffer) );
+
+ CObexPacket* self = new (ELeave) CObexPacket ( aBufferSize, aDataLimit );
+ CleanupStack::PushL (self);
+ self->ConstructL ();
+ CleanupStack::Pop (self);
+ return (self);
+ }
+
+void CObexPacket::ConstructL ()
+ {
+// FTRACE(FPrint(_L("CObexPacket::ConstructL buffer %d data limit %d"), iBufferSize, iDataLimit));
+
+ iBuffer = new (ELeave) TUint8 [ iBufferSize ];
+ Init ( 0 );
+ }
+/**
+Set up as a fresh packet with the given opcode.
+@param aOpcode a opcode
+*/
+EXPORT_C void CObexPacket::Init (TObexOpcode aOpcode)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ SetOpcode (aOpcode);
+ SetPacketSize (KObexPacketHeaderSize);
+ iInsertPoint = Payload ();
+ iExtractPoint = Payload ();
+ iNotificationEvents = 0;
+ }
+
+/**
+Returns the packet opcode, with the final bit cleared (regardless of its actual value)
+@return TObexOpcode
+*/
+EXPORT_C TObexOpcode CObexPacket::Opcode () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return (STATIC_CAST(TObexOpcode, iBuffer[0] & ~KObexPacketFinalBit));
+ }
+
+/**
+Set the packet opcode to the passed value -- final bit will get through too.
+@param aOpcode an Opcode
+*/
+EXPORT_C void CObexPacket::SetOpcode (TObexOpcode aOpcode)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iBuffer[0] = aOpcode;
+ }
+
+/**
+True if the packet's final bit is set
+@return TBool true if this is the final packet
+*/
+EXPORT_C TBool CObexPacket::IsFinal () const
+ {
+ LOG_LINE
+
+ const TBool isFinal = (iBuffer[0] & KObexPacketFinalBit);
+
+ LOG1(_L8("CObexPacket::IsFinal returning %d"), isFinal);
+
+ return isFinal;
+ }
+
+/**
+If aFinal == ETrue (default), the final bit is set, otherwise it is cleared.
+@param aFinal whether or not to set or clear the final bit
+*/
+EXPORT_C void CObexPacket::SetFinal (TBool aFinal)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iBuffer[0] = STATIC_CAST(TObexOpcode, aFinal ? (iBuffer[0] | KObexPacketFinalBit) : (iBuffer[0] & ~KObexPacketFinalBit));
+ }
+
+/**
+Returns the total size of the current packet.
+@return TUint16 total size of the packet
+*/
+EXPORT_C TUint16 CObexPacket::PacketSize () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return (BigEndian::Get16 (&iBuffer[1]));
+ }
+
+/**
+Sets the crruent packet's size.
+@param aSize a packet size
+*/
+EXPORT_C void CObexPacket::SetPacketSize (TUint16 aSize)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ BigEndian::Put16 (&iBuffer[1], aSize);
+ }
+
+/**
+Sets the data limit of the buffer, ensuring it's larger than minimum possible but not larger than the buffer
+Parameter passed in is the requested new data limit
+Returns size that was set
+@param aRequestedSize a Requested size for the data limit
+@return TUint16 the data limit size
+*/
+EXPORT_C TUint16 CObexPacket::SetLegalDataLimit (TUint16 aRequestedSize)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+// FTRACE(FPrint(_L("CObexPacket::SetLegalDataLimit requested size %d"), aRequestedSize));
+
+ aRequestedSize = Max ( KObexPacketMinSize, aRequestedSize );
+ aRequestedSize = Min ( iBufferSize, aRequestedSize );
+
+// FTRACE(FPrint(_L("CObexPacket::SetLegalDataLimit set size %d"), aRequestedSize));
+ iDataLimit = aRequestedSize;
+ return iDataLimit;
+ }
+
+/**
+return the data limit
+@return TUint16 the data limit
+*/
+EXPORT_C TUint16 CObexPacket::DataLimit () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iDataLimit;
+ }
+
+/**
+return the buffer size
+@return TUint16 the buffer size
+*/
+EXPORT_C TUint16 CObexPacket::BufferSize() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return iBufferSize;
+ }
+
+/**
+Insert the passed packet data object at iInsertPoint
+@param aHeader OBEX header to insert
+@return True if the number of bytes is not zero and there is enough space to insert data
+*/
+EXPORT_C TBool CObexPacket::InsertData (const TObexData& aHeader)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (aHeader.TotalSize () > RemainingInsertSpace ()) return EFalse;
+ TUint16 bytesInserted = aHeader.WriteOut (iInsertPoint, RemainingInsertSpace ());
+ iInsertPoint += bytesInserted;
+ SetPacketSize (STATIC_CAST(TUint16, PacketSize () + bytesInserted));
+ return (bytesInserted != 0);
+ }
+
+/**
+Extract into the passed data object from iExtractPoint
+@param aHeader Container for extracted data
+@return True if bytes read is not zero
+*/
+EXPORT_C TBool CObexPacket::ExtractData (TObexData& aHeader)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ TUint16 bytesRead = aHeader.ParseIn (iExtractPoint, RemainingExtractSpace ());
+ iExtractPoint += bytesRead;
+
+ // If no bytes have been read two possible conditions have occured
+ // 1. There is no remaining extract space in the packet (i.e. at the end)
+ // 2. There has been an error when parsing.
+ // In either case iExtractPoint will not move and aHeader has not really
+ // changed its state (iHI, iHV, iHVSize and iHVRep will change but get
+ // reset on the next ParseIn. So if no bytes are read then from the API we
+ // assume that we have finished processing the packet, and so can reset the
+ // extract point, in case it needs to be parsed again.
+ if (bytesRead == 0)
+ {
+ iExtractPoint = Payload();
+ }
+
+ return (bytesRead != 0);
+ }
+
+/**
+Returns the number of bytes of unused space in the obex packet (on writes)
+@return Remaining insert space
+*/
+EXPORT_C TUint16 CObexPacket::RemainingInsertSpace () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG (iInsertPoint >= Payload () && iInsertPoint <= &iBuffer[iDataLimit], PANIC(KPanicCat, EPacketOverrun));
+ return (TUint16)((&iBuffer[iDataLimit]) - iInsertPoint);
+ }
+
+/**
+Returns the number of bytes of unread data in the obex packet (on reads)
+@return Remaining extract space
+*/
+EXPORT_C TUint16 CObexPacket::RemainingExtractSpace () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG (iExtractPoint >= Payload () && iExtractPoint <= &iBuffer[PacketSize ()], PANIC (KPanicCat, EPacketOverrun));
+ return (TUint16)((&iBuffer[PacketSize ()] - iExtractPoint));
+ }
+
+/** Adds events that should be notified.
+
+Add events into the packet process events mask. When this packet
+is processed this mask will be checked and notifications will be
+issued only if the appropriate bits are set.
+
+@param aEvents The additional events to notify on.
+*/
+EXPORT_C void CObexPacket::AddPacketProcessEvents(TObexPacketProcessEvents aEvents)
+ {
+ LOG_LINE
+ LOG_FUNC
+ iNotificationEvents |= aEvents;
+ }
+
+/** Removes events from packet notification.
+
+Remove events from the packet process events mask. When this packet
+is processed this mask will be checked and notifications will be
+issued only if the appropriate bits are set.
+
+@param aEvents The events to cease notification of.
+*/
+EXPORT_C void CObexPacket::RemovePacketProcessEvents(TObexPacketProcessEvents aEvents)
+ {
+ LOG_LINE
+ LOG_FUNC
+ iNotificationEvents &= ~aEvents;
+ }
+
+/** Gets events that will be notified.
+
+Retrieves the packet process events mask. When this packet
+is processed this mask will be checked and notifications will be
+issued only if the appropriate bits are set.
+
+@return The events that will be notified.
+*/
+EXPORT_C TObexPacketProcessEvents CObexPacket::PacketProcessNotificationEvents() const
+ {
+ LOG_LINE
+ LOG_FUNC
+ return iNotificationEvents;
+ }
+
+/**
+Logs the size of the packet.
+If __LOG_PACKET_DUMP__ is defined (obex/common/logger.h) then also logs the
+packet's contents.
+*/
+EXPORT_C void CObexPacket::Dump () const
+ {
+ LOG1(_L8("PacketSize = %d, Packet Dump:"), PacketSize ());
+#ifdef __LOG_PACKET_DUMP__
+ LOGHEXRAW(iBuffer, iBufferSize);
+#endif
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/src/obextransportcontrollerbase.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,594 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <ecom/ecom.h>
+#include <obex/transport/obextransportcontrollerbase.h>
+#include <obex/internal/mobexnotifyextend.h>
+#include <obexirtransportinfo.h>
+#include <obex/internal/obexactiverw.h>
+#include <obextransportinfo.h>
+#include <obex/internal/obexpacket.h>
+#include <obexpanics.h>
+#include "ObexTransportUtil.h"
+#include "obexconnectdata.h"
+#include "logger.h"
+#include "obextransportfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "OBEXCT");
+#endif
+
+//Category used for internal panics
+_LIT(KPanicCat, "TransCTBase");
+
+// The minimum allowed number of 'transport controller' implementations. If
+// NewL doesn't find at least this many, then in debug NewL panics, and in
+// release it leaves.
+const TUint KMinimumNumImplementations = 1;
+
+/**
+Constructs a CObexTransportControllerBase PlugIn object.
+
+@internalTechnology
+@return A new CObexTransportControllerBase PlugIn object
+@panic TransCTBase EInvalidNumberOfTransportImplementations if there is more than one implementation for a given interface uid and transport name (equal to the default data in the plugin resource file
+*/
+EXPORT_C CObexTransportControllerBase* CObexTransportControllerBase::NewL(TObexTransportInfo& aTransportInfo)
+ {
+ LOG_LINE
+ LOG_STATIC_FUNC_ENTRY
+
+ //Making a copy as Collapse modifies the original iTransportName
+ TBuf<60> transportName = aTransportInfo.iTransportName;
+ TPtrC8 params = transportName.Collapse();
+ TEComResolverParams resolverParams;
+ resolverParams.SetDataType(*reinterpret_cast<TDesC8*>(¶ms));
+
+ RImplInfoPtrArray implInfoArray;
+ REComSession::ListImplementationsL(TUid::Uid(KObexTransportControllerInterfaceUid), resolverParams, KRomOnlyResolverUid, implInfoArray);
+
+ CleanupResetAndDestroyPushL(implInfoArray);
+ __ASSERT_DEBUG(implInfoArray.Count() <= KMinimumNumImplementations, PANIC(KObexTransportPanicCat, EInvalidNumberOfTransportImplementations) );
+ if (implInfoArray.Count() < KMinimumNumImplementations)
+ {
+ User::Leave(KErrNotFound);
+ }
+
+ const TUid uid = implInfoArray[KMinimumNumImplementations - 1]->ImplementationUid();
+ CleanupStack::PopAndDestroy(&implInfoArray);
+
+ CObexTransportControllerBase* ptr = reinterpret_cast<CObexTransportControllerBase*>
+ (REComSession::CreateImplementationL(uid, _FOFF(CObexTransportControllerBase, iPrivateEComUID),
+ reinterpret_cast<TAny*>(&aTransportInfo)));
+
+ CleanupStack::PushL(ptr);
+ // Do any base construction here. This may in future include allocation of
+ // iFuture1.
+ ptr->BaseConstructL();
+ CleanupStack::Pop(ptr);
+ return ptr;
+ }
+
+/**
+Constructor.
+
+@publishedPartner
+@released
+*/
+EXPORT_C CObexTransportControllerBase::CObexTransportControllerBase()
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+/**
+This function is a place holder for future use. If iFuture1 variable is used
+it will need this function for any allocation required.
+This function is called from CObexTransportControllerBase::NewL.
+*/
+void CObexTransportControllerBase::BaseConstructL()
+ {
+ LOG_LINE
+ LOG_FUNC
+ }
+
+/**
+Sets the owner information from the received aOwner
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::SetOwner(MObexNotifyExtend& aOwner)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_ALWAYS(iOwner==NULL, PANIC(KPanicCat, EOwnerAlreadySet));
+ iOwner = &aOwner;
+ }
+
+/**
+Destructor.
+
+@publishedPartner
+@released
+*/
+EXPORT_C CObexTransportControllerBase::~CObexTransportControllerBase()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ delete iConnector;
+ DeleteTransport();
+ delete iTransportInfo;
+
+ REComSession::DestroyedImplementation(iPrivateEComUID);
+ }
+/**
+Cancels outstanding reads or writes
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::CancelTransfers()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iActiveReader)
+ {
+ iActiveReader->Cancel();
+ }
+ if (iActiveWriter)
+ {
+ iActiveWriter->Cancel();
+ }
+ }
+/**
+Calls on the constructor to take down the transport
+
+@internalTechnology
+@return TBool ETrue if the transport was taken down
+*/
+EXPORT_C TBool CObexTransportControllerBase::BringTransportDown()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ DeleteTransport();
+ return iConnector->BringTransportDown();
+ }
+
+/**
+Calls ConnectL on the connector
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::ConnectL ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iConnector->ConnectL();
+ }
+
+/**
+Ask Connector to cancel connect
+
+@see CObexTransportControllerBase::ConnectL
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::CancelConnect()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iConnector->CancelConnect();
+ }
+
+/**
+Calls accept connection on the connector
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::AcceptConnectionL()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iConnector->AcceptL();
+ }
+
+/**
+Calls Cancel Accept on he connector
+
+@see CObexTransportControllerBase::AcceptConnectionL
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::CancelAccept()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if ( iConnector)
+ {
+ iConnector->CancelAccept();
+ }
+ }
+
+/**
+Calls signal transport error on the connector
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::SignalTransportError()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ // If this is called during construction, iConnector could be NULL
+ if(iConnector)
+ {
+ iConnector->SignalTransportError();
+ }
+ }
+
+/**
+returns the send packet
+
+@return CObexPacket the packet that will be sent
+@internalTechnology
+*/
+EXPORT_C CObexPacket& CObexTransportControllerBase::SendPacket ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return *iSendPacket;
+ }
+
+/**
+Returns the packet received
+
+@return CObexPacket the packet that will be sent
+@internalTechnology
+*/
+EXPORT_C CObexPacket& CObexTransportControllerBase::ReceivePacket ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return *iReceivePacket;
+ }
+
+/**
+Ask active writer to do a send
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::Send ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ LOG3(_L8("Packet Sent, Opcode 0x%2x (0x%2x with final bit cleared), Length %d"), (iSendPacket->IsFinal() ? (iSendPacket->Opcode() | KObexPacketFinalBit) : iSendPacket->Opcode()), iSendPacket->Opcode(), iSendPacket->PacketSize());
+ FTRACE(iSendPacket->Dump ());
+
+ iActiveWriter->Transfer (*iSendPacket);
+ }
+
+/**
+Init the send packet wtih the received, aOpcode, set final to true, and send the packet
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::Send (TObexOpcode aOpcode)
+ {
+ LOG_LINE
+ LOG_FUNC
+ LOG1(_L8("\taOpcode = %d"), aOpcode);
+
+ iSendPacket->Init (aOpcode);
+ iSendPacket->SetFinal (ETrue);
+ Send ();
+ }
+
+/**
+Ask activer reader to do a read
+
+@internalTechnology
+*/
+EXPORT_C void CObexTransportControllerBase::Receive ()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ iActiveReader->Transfer (*iReceivePacket);
+ }
+
+/**
+Is there a write outstanding
+
+@return TBool return ETrue is there is a write activer otherwise EFalse
+@internalTechnology
+*/
+EXPORT_C TBool CObexTransportControllerBase::IsWriteActive () const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iActiveWriter)
+ {
+ return (iActiveWriter->IsActive());
+ }
+ else // this has been added incase of null iActiveWriter
+ {
+ return EFalse;
+ }
+ }
+
+/**
+Insert local Connection info with the received, aVersion, aFlags and from iReceivePacket into the receive packet, aPacket
+
+@return TInt KErrNone or a symbian error
+@param aPacket the packet that is updated with local connection info
+@param aVersion
+@param aFlags
+@internalTechnology
+*/
+EXPORT_C TInt CObexTransportControllerBase::InsertLocalConnectInfo (CObexPacket &aPacket, TUint8 aVersion, TUint8 aFlags)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iReceivePacket)
+ {
+ TObexConnectData localinfo;
+ localinfo.iVersion = aVersion;
+ localinfo.iFlags = aFlags;
+ localinfo.iMaxPacketLength = iReceivePacket->DataLimit(); // maximum packet length we can receive
+ return (aPacket.InsertData (localinfo));
+ }
+ else
+ {
+ return KErrGeneral;
+ }
+ }
+
+/**
+Extract the local information from the received packet
+
+@return EFalse- failed to extract the information. ETrue- extraction succeeded.
+@param aPacket The packet from which local connection info is extracted
+@param aVersion
+@param aFlags
+@internalTechnology
+*/
+EXPORT_C TBool CObexTransportControllerBase::ExtractRemoteConnectInfo(CObexPacket &aPacket, TUint8& aVersion, TUint8& aFlags)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ if (iSendPacket)
+ {
+ TObexConnectData remoteinfo;
+ if (!aPacket.ExtractData (remoteinfo))
+ {
+ return EFalse;
+ }
+ aVersion = remoteinfo.iVersion;
+ aFlags = remoteinfo.iFlags;
+
+ // Set the send buffer data limit (i.e. how much OBEX can use) to match the size of the
+ // remote receive buffer (the setter function ensures it's a legal size)
+ (void)iSendPacket->SetLegalDataLimit (remoteinfo.iMaxPacketLength);
+ return ETrue;
+ }
+ else
+ {
+ return EFalse;
+ }
+ }
+
+/**
+@internalTechnology
+*/
+void CObexTransportControllerBase::ConstructPacketsL()
+ {
+ LOG_FUNC
+
+ // Set actual packet sizes
+ // Receive must be at least KObexPacketDefaultSize to maintain functional compatibility with previous implentations
+ // (to ensure that remote ends that ignore how big we say our receive buffer is get that same grace on buffer overflow)
+ __ASSERT_DEBUG(iTransportInfo, PANIC(KPanicCat, ETransportNullPointer));
+ TUint16 receivePacketBufferSize = Max ( iTransportInfo->iReceiveMtu, KObexPacketDefaultSize );
+ TUint16 sendPacketBufferSize = iTransportInfo->iTransmitMtu;
+
+ // Set initial "software throttle" for packets (how big OBEX says they are)
+ // Send packet is set to miniumum, so initial transmit cannot overflow remote end
+ TUint16 receivePacketDataLimit = GetReceivePacketDataLimit();
+ TUint16 sendPacketDataLimit = KObexPacketMinSize;
+
+ LOG2(_L8("CObexTransportControllerBase::ConstructPacketsL send buffer %d send data limit %d"), sendPacketBufferSize, sendPacketDataLimit);
+ LOG2(_L8("CObexTransportControllerBase::ConstructPacketsL receive buffer %d receive data limit %d"), receivePacketBufferSize, receivePacketDataLimit);
+
+ // Create the packets
+ iSendPacket = CObexPacket::NewL(sendPacketBufferSize, sendPacketDataLimit);
+ iReceivePacket = CObexPacket::NewL(receivePacketBufferSize, receivePacketDataLimit);
+ }
+
+/**
+Gets the socket associated with the connector and asks the socket for its remote name.
+This can be cast to the appropriate TSockAddr-derived class TIrdaSockAddr for IrDA.
+
+@publishedPartner
+@released
+*/
+EXPORT_C void CObexTransportControllerBase::RemoteAddr(TSockAddr& aAddr)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ DoRemoteAddr(aAddr);
+ }
+
+/**
+Returns true if the derived transport can re-connect when an obex connection is re-connected
+This is used to determine whether to take the transport down when an obex connection has been disconnected
+
+@see DoIsTransportRestartable
+@return TBool return ETrue if the derived transport can support re-connection when obex re-connects
+@publishedPartner
+@released
+*/
+EXPORT_C TBool CObexTransportControllerBase::IsTransportRestartable() const
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ return DoIsTransportRestartable();
+ }
+
+//MObexTransport Notify Protected
+/**
+Process a Packet. Upcall to the owner
+
+@publishedPartner
+@released
+*/
+EXPORT_C void CObexTransportControllerBase::DoProcess(CObexPacket &aPacket)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iOwner, PANIC(KPanicCat, ETransportNullPointer));
+ iOwner->Process(aPacket);
+ }
+
+/**
+Reports and error to the owner
+
+@publishedPartner
+@released
+*/
+EXPORT_C void CObexTransportControllerBase::DoError(TInt aError)
+ {
+ LOG_LINE
+ LOG_FUNC
+ LOG1(_L8("\taError = %d"), aError);
+
+ __ASSERT_DEBUG(iOwner, PANIC(KPanicCat, ETransportNullPointer));
+ iOwner->Error(aError);
+ }
+
+/**
+Create the transport objects and reports that the transport is up to the owner
+
+@publishedPartner
+@released
+*/
+EXPORT_C void CObexTransportControllerBase::DoTransportUp(TObexConnectionInfo& aInfo)
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ DeleteTransport();
+ TRAPD(err, InitialiseTransportL(aInfo));
+ if(err != KErrNone)
+ {
+ TransportUpError(err);
+ }
+ else
+ {
+ __ASSERT_DEBUG(iOwner, PANIC(KPanicCat, ETransportNullPointer));
+ iOwner->TransportUp();
+ Receive();
+ }
+ }
+
+void CObexTransportControllerBase::InitialiseTransportL(TObexConnectionInfo& aInfo)
+ {
+ NewTransportL(aInfo);
+ ConstructPacketsL();
+ }
+
+void CObexTransportControllerBase::TransportUpError(TInt aError)
+ {
+ // At this stage the transport controller will have a connection set-up.
+ // As a result if we get an error while setting up Obex we should bring
+ // the transport down (the owner has alrady been informed of the error,
+ // but we shouldn't expect them to have to bring the transport down).
+ TBool broughtDown = BringTransportDown();
+ // If we failed to bring down the transport there isn't much
+ // more we can do.
+ (void)broughtDown;
+
+ Error(aError); // Signal error indication
+ }
+
+/**
+Signals that an event related to processing the packet has occurred.
+@param aEvent The event that has occurred.
+*/
+EXPORT_C void CObexTransportControllerBase::DoSignalPacketProcessEvent(TObexPacketProcessEvent aEvent)
+ {
+ LOG_FUNC
+
+ __ASSERT_DEBUG(iOwner, PANIC(KPanicCat, ETransportNullPointer));
+ iOwner->SignalPacketProcessEvent(aEvent);
+ }
+
+/**
+Returns a pointer to the transport info being used by the transport. This may
+be cast to the transport info type associated with the known concrete
+transport controller.
+*/
+EXPORT_C const TObexTransportInfo* CObexTransportControllerBase::TransportInfo() const
+ {
+ LOG_FUNC
+
+ return iTransportInfo;
+ }
+
+/**
+This function is part of the extension pattern and must be implemented by all derived instantiable classes.
+By default this returns null. Any derived class that is required to extend its interface and that of this base
+class returns its new interface in the form of an M class, that it extends, if and only if the corresponding TUid,
+aUid, is received. Otherwise the function calls the base class implementation, returning NULL.
+
+@return The M Class representing the extension to the interface otherwise NULL
+@param aUid The uid associated with the M Class that is being implemented
+@publishedPartner
+@released
+*/
+EXPORT_C TAny* CObexTransportControllerBase::GetInterface(TUid /*aUid*/)
+ {
+ LOG_FUNC
+
+ return NULL;
+ }
+
+//private
+void CObexTransportControllerBase::DeleteTransport()
+ {
+ LOG_LINE
+ LOG_FUNC
+
+ delete iActiveWriter;
+ delete iActiveReader;
+ delete iReceivePacket;
+ delete iSendPacket;
+ iActiveWriter = NULL;
+ iActiveReader = NULL;
+ iReceivePacket = NULL;
+ iSendPacket = NULL;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/group/t_obextransportheadercheck.mmp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,51 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Pointless file produced by test project; the test is that it
+// compiles at all.
+//
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+target t_obextransportheadercheck.exe
+targettype exe
+uid 0
+VENDORID 0x70000001
+
+sourcepath ../src
+source main.cpp
+source t_mobexnotify.cpp
+source t_mobextransportnotify.cpp
+source t_obexactivereader.cpp
+source t_obexactiverw.cpp
+source t_obexactivewriter.cpp
+source t_obexconnector.cpp
+source t_obexdata.cpp
+source t_obexinternalconstants.cpp
+source t_obexinternalheader.cpp
+source t_obexpacket.cpp
+source t_ObexReaderBase.cpp
+source t_obextransportconstants.cpp
+source t_obextransportcontrollerbase.cpp
+source t_ObexWriterBase.cpp
+source t_mobexnotifyextend.cpp
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+library euser.lib
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/main.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,21 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32std.h>
+
+GLDEF_C TInt E32Main()
+ {
+ return KErrNone;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_ObexReaderBase.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexreaderbase.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_ObexWriterBase.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexwriterbase.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_Obextransport.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex\transport\obextransport.hrh>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_mobexnotify.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <mobexnotify.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_mobexnotifyextend.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/mobexnotifyextend.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_mobextransportnotify.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/mobextransportnotify.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexactivereader.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexactivereader.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexactiverw.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexactiverw.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexactivewriter.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexactivewriter.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexconnector.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obexconnector.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexdata.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexdata.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexinternalconstants.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexinternalconstants.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexinternalheader.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexinternalheader.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obexpacket.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obexpacket.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obextransportconstants.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/internal/obextransportconstants.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obextransport/test/headercheck/src/t_obextransportcontrollerbase.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,16 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <obex/transport/obextransportcontrollerbase.h>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/group/ObexUsbTransportController.mmp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,52 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// ObexUsbTransportController.dll Obex USB Controller plug-in, used to load the USB transport.
+// ObexUsbTransportController.rsc The rsc file for the USB controller plug-in, used by ECOM to locate the correct plugin.
+//
+//
+
+/**
+ @file
+*/
+
+
+target obexusbtransportcontroller.dll //Recommended unpaged
+CAPABILITY All -Tcb
+targettype plugin
+
+// ECom Dll recognition UID followed by the unique dll UID
+UID 0x10009d8d 0x1020de87
+VENDORID 0x70000001
+
+SOURCEPATH ../src
+SOURCE ObexUsbImpCollection.cpp
+SOURCE ObexUsbTransportController.cpp
+SOURCE usbconn.cpp
+
+START resource 1020DE87.rss
+target obexusbtransportcontroller.rsc
+END
+
+USERINCLUDE ../inc
+USERINCLUDE ../../common
+
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY euser.lib
+LIBRARY obexcommontransport.lib
+
+//Since this component is a plug-in, there is no need to produce a .lib file.
+NOEXPORTLIBRARY
+
+SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/group/bld.inf Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,17 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_MMPFILES
+ObexUsbTransportController.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/inc/ObexUsbTransportController.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,55 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef __OBEXUSBTRANSPORTCONTROLLER_H__
+#define __OBEXUSBTRANSPORTCONTROLLER_H__
+
+#include <obex/transport/obextransportcontrollerbase.h>
+
+/**
+CObexUsbTransportController
+Transport Controller for the usb transport
+*/
+NONSHARABLE_CLASS(CObexUsbTransportController) : public CObexTransportControllerBase
+ {
+public://NewL functions
+ static CObexUsbTransportController* NewL(TObexTransportInfo& aTransportInfo);
+
+public://Functions derived from CBase
+ virtual ~CObexUsbTransportController();
+
+public://Functions derived from CObexTransportControllerBase
+ virtual void DoRemoteAddr(TSockAddr& aAddr);
+ virtual void NewTransportL(TObexConnectionInfo& aInfo);
+ virtual TBool DoIsTransportRestartable() const;
+ TUint16 GetReceivePacketDataLimit();
+
+public://Functions implemented from MObexTransportNotify
+ virtual void DoProcess(CObexPacket &aPacket) ;
+ virtual void DoError(TInt aError) ;
+ virtual void DoTransportUp(TObexConnectionInfo& aInfo);
+
+private:
+ void ConstructL(TObexTransportInfo& aTransportInfo);
+ CObexUsbTransportController();
+ };
+
+#endif //__OBEXUSBTRANSPORTCONTROLLER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/inc/obexusbfaults.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,33 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __OBEXUSBFAULTS_H
+#define __OBEXUSBFAULTS_H
+/**
+@file
+
+This file contains usb specific panics internal to obex
+@internalComponent
+*/
+
+enum TObexUsbFaultCode
+ {
+ EUnknownUsbState = 0,
+ EUnknownUsbTransport = 1,
+ EDmaAllocationFailedEndpointIn = 2,
+ EDmaAllocationFailedEndpointOut = 3,
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/inc/usbconn.h Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,297 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef __USBCONN_H__
+#define __USBCONN_H__
+
+#include <e32base.h>
+#include <usb.h>
+#include <d32usbc.h>
+#include <obex/transport/obexreaderbase.h>
+#include <obex/transport/obexwriterbase.h>
+#include <obex/transport/obexconnector.h>
+#include <obex/transport/mobextransportnotify.h>
+#include <obexconstants.h>
+#include <obexusbtransportinfo.h>
+#include "ObexUsbTransportController.h"
+
+//
+// LDD name
+//
+_LIT(KUsbLddName, "eusbc");
+
+// Transmit and receive endpoints
+// Note that these are the virtual endpoint numbers for the bulk interface and
+// should be put in the same order in the TUsbcEndpointInfo array in RegInterfacesL
+const TEndpointNumber KTransmitEndpoint = EEndpoint1;
+const TEndpointNumber KReceiveEndpoint = EEndpoint2;
+
+// These are taken from section 6.5 of the WMCDC spec.
+const TUint KObexDescriptorLength = 18;
+const TUint KObexMinNumEndpoints = 3;
+const TUint KObexClassNumber = 0x02;
+const TUint KObexNumInterfaces = 2;
+const TUint KObexSubClassNumber = 0x0b;
+const TUint KObexProtocolNumber = 0x0;
+const TUint KObexTotalEndpoints = 2;
+
+const TUint KObexDataClass = 0x0A;
+const TUint KObexDataSubClass = 0;
+const TUint KObexAlt0 = 0;
+const TUint KObexAlt1 = 1;
+const TUint KObexFunctionalDescriptorLength = 5;
+const TUint KObexDefaultInterfaceDescriptorLength = 100; //Default value used prior to OS 9.2
+const TUint KObexInterfaceDescriptorBlockLength = 16;
+
+const TUint8 KCdcVersionNumber[2] = { 0x10, 0x01 }; // CDC v1.1
+const TUint8 KHeaderFunctionalDescriptor = 0x00;
+const TUint8 KObexFunctionalDescriptor = 0x15;
+const TUint8 KWmcdcVersionNumber[2] = { 0x00, 0x01 }; // WMCDC v1.0
+const TUint8 KUnionFunctionalDescriptor = 0x06;
+
+const TInt KMaxPacketTypeBulkFS = 64;
+const TInt KMaxPacketTypeBulkHS = 512;
+
+
+/**
+USB Active Writer class
+*/
+NONSHARABLE_CLASS(CObexUsbActiveWriter) : public CObexWriterBase
+//------------------------------------------------------------------------------------
+ {
+public:
+ static CObexUsbActiveWriter* NewL(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo, TInt aPacketSize);
+ ~CObexUsbActiveWriter();
+
+private:
+ virtual void DoCancel();
+ virtual void DoTransfer();
+
+private:
+ CObexUsbActiveWriter(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo, TInt aPacketSize);
+
+private:
+ RDevUsbcClient& iUsb; // USB logical device driver
+ TInt iPacketSize;
+ };
+
+
+/**
+USB Active Reader class
+*/
+NONSHARABLE_CLASS(CObexUsbActiveReader) : public CObexReaderBase
+//------------------------------------------------------------------------------------
+ {
+public:
+ static CObexUsbActiveReader* NewL(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo);
+ ~CObexUsbActiveReader();
+
+private:
+ virtual void DoCancel();
+ virtual void DoTransfer();
+ virtual TInt GetMaxPacketSize();
+ virtual TInt GetInitialPacketSize();
+private:
+ CObexUsbActiveReader(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo);
+private:
+ RDevUsbcClient& iUsb; // USB logical device driver
+ TBool iGotHeader;
+ };
+
+
+/**
+Used by the USB underlying object to notify changes in the transport link.
+*/
+NONSHARABLE_CLASS(MObexUsbConnector)
+//------------------------------------------------------------------------------------
+ {
+public:
+ /**
+ @internalComponent
+ Called in response to the USB transport coming up.
+ */
+ virtual void TransportUp() =0;
+
+ /**
+ @internalComponent
+ Called in response to the USB transport going down.
+ @param aErr An error value associated with the transport down event.
+ */
+ virtual void TransportDown(TInt aErr = KErrDisconnected) =0;
+
+ /**
+ @internalComponent
+ Called when an endpoint stall has been cleared.
+ */
+ virtual void StallCleared() =0;
+ };
+
+
+/**
+Handles the underlying details of a USB connection. Monitors the state of
+the transport and notifies owner as transport goes up and down.
+*/
+NONSHARABLE_CLASS(CObexUsbHandler) : public CActive
+//------------------------------------------------------------------------------------
+ {
+public:
+ virtual ~CObexUsbHandler();
+
+ static CObexUsbHandler* NewL(TObexUsbTransportInfo& aUsbTransportInfo,
+ MObexUsbConnector& aOwner, RDevUsbcClient& aUsb);
+
+ void Start();
+
+ // Implements CActive
+ void RunL();
+ TInt RunError(TInt /*aError*/);
+
+private:
+ CObexUsbHandler(TObexUsbTransportInfo& aUsbProtocolInfo, MObexUsbConnector& aOwner, RDevUsbcClient& aUsb);
+ void DoCancel();
+ void ConstructL();
+ void RegInterfacesL();
+ void AllocateDma();
+ static void CleanupReleaseInterface0(TAny* aInterface);
+
+private:
+ TObexUsbTransportInfo& iObexTransportInfo; // Note: Cannot assume this is valid outside of construction phases
+ MObexUsbConnector& iOwner;
+
+ RDevUsbcClient& iUsb; // USB LDD used for Data Class interface
+ RDevUsbcClient iUsbComms; // USB LDD used for Comms Class interface
+
+ TUint iUsbState; // Used by RDevUsbcClient::AlternateDeviceStatusNotify()
+ TBool iTransportUp; // TRUE when device is configured
+
+ // Interface performance configuration parameters
+ // (for extended USB Client Driver API)
+ TInt iBandwidthPriority;
+ TBool iRequestDmaOnOutEndpoint;
+ TBool iRequestDmaOnInEndpoint;
+ };
+
+
+/**
+Class to stall then monitor an endpoint and notify owner when the halt state has been cleared.
+*/
+NONSHARABLE_CLASS(CObexUsbStaller) : public CActive
+//------------------------------------------------------------------------------------
+ {
+public:
+ static CObexUsbStaller* NewL(RDevUsbcClient& aUsb, MObexUsbConnector& iOwner);
+ ~CObexUsbStaller();
+
+ void Start();
+
+private:
+ CObexUsbStaller(RDevUsbcClient& aUsb, MObexUsbConnector& iOwner);
+
+ virtual void DoCancel();
+ virtual TInt RunError(TInt /*aError*/);
+ virtual void RunL();
+
+private:
+ RDevUsbcClient& iUsb;
+ MObexUsbConnector& iOwner;
+ TUint iEndpointStatus;
+ };
+
+
+/**
+Class to support connecting to other USB devices.
+Server mode is relatively straightforward as this corresponds
+exactly to how USB works from the device perspective. Obex client
+support though requires some 'magic'.
+*/
+NONSHARABLE_CLASS(CObexUsbConnector) : public CObexConnector, public MObexUsbConnector
+//------------------------------------------------------------------------------------
+ {
+public:
+ /**
+ This enum holds the three different states which the connector
+ can be in. In DefaultClient mode, the connector is behaving as
+ a client but can be switched to server behaviour. Once the mode
+ has been moved out of DefaultClient (to either Client or Server),
+ the mode is locked for the lifetime of the object. Other
+ connectors can provide different behaviour for other CObexServer
+ or CObexClient objects.
+ */
+ enum TObexUsbMode
+ {
+ EDefaultClient,
+ EClient,
+ EServer
+ };
+ static CObexUsbConnector* NewL(MObexTransportNotify& aOwner, TObexUsbTransportInfo& aUsbTransportInfo);
+ CObexUsbConnector (MObexTransportNotify& aOwner, TObexUsbTransportInfo& aUsbTransportInfo);
+
+ ~CObexUsbConnector();
+
+ virtual void ConstructL();
+
+ //Implement MObexUsbConnector interface
+ virtual void TransportUp();
+ virtual void TransportDown(TInt aErr = KErrDisconnected);
+ virtual void StallCleared();
+
+ //Overrides for pure virtuals in CObexConnector
+ virtual void ConnectL();
+ virtual void CancelConnect();
+ virtual void AcceptL();
+ virtual void CancelAccept();
+ virtual TBool BringTransportDown();
+ virtual void SignalTransportError();
+
+ //required to pass the RDevUsbcClient to the activer reader and writer
+ RDevUsbcClient* TransportObject();
+ TInt GetTransportPacketSize();
+
+private:
+ void OpenUsbL(TInt aUnit);
+ static TInt LinkUp(TAny* aConn);
+ static TInt NoDevice(TAny* aConn);
+ void SignalUp();
+ void SignalDown(TInt aErr);
+
+ void ResetTransportPacketSize();
+ void SetTransportPacketSize();
+
+// Data
+private:
+ RDevUsbcClient iUsb; // USB logical device driver
+ // Note: This is the handle used for reads and writes.
+ TObexUsbTransportInfo& iObexTransportInfo; // Reference to protocol info to pass on to CObexUsbHandler
+ // Note: Cannot assume this is valid outside of construction phases
+ TObexUsbMode iMode;
+
+ CAsyncCallBack* iCallback;
+ TBool iTransportLinkAvailable;
+ TBool iConnectRequested;
+ TBool iWaitingForLink;
+ CObexUsbHandler* iHandler;
+ CObexUsbStaller* iStaller;
+
+ TInt iPacketSize;
+ };
+
+
+#endif /* __USBCONN_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/src/1020DE87.rss Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,48 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "ecom/registryinfo.rh"
+#include <obex/transport/obextransport.hrh>
+
+RESOURCE REGISTRY_INFO theInfo
+ {
+ dll_uid = 0x1020DE87;
+ interfaces =
+ {
+ INTERFACE_INFO
+ {
+ interface_uid = KObexTransportInterfaceUid;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x1020DE88;
+ version_no = 1;
+ display_name = "Obex USB";
+ default_data = "USB";
+ opaque_data = "";
+ },
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x1020DEA4;
+ version_no = 1;
+ display_name = "Obex USB-V2";
+ default_data = "USB-V2";
+ opaque_data = "";
+ }
+ };
+ }
+ };
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/src/ObexUsbImpCollection.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,44 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "ObexUsbTransportController.h"
+
+/**
+Define the private interface UIDs
+2 implementations are defined to cater for the USB and USB-V2 variants. Both
+interfaces call the same NewL function.
+ECOM passes a TObexTransportInfo parameter. The iTransportName member will
+be used to cast the parameter to the correct type.
+*/
+const TImplementationProxy ObexTCImplementationTable[] =
+ {
+ IMPLEMENTATION_PROXY_ENTRY(0x1020de88, CObexUsbTransportController::NewL),//USB implementation
+ IMPLEMENTATION_PROXY_ENTRY(0x1020dea4, CObexUsbTransportController::NewL),//USB V2 implementation
+ };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+ {
+ aTableCount = sizeof(ObexTCImplementationTable) / sizeof(TImplementationProxy);
+
+ return ObexTCImplementationTable;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/src/ObexUsbTransportController.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,190 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include <c32comm.h>
+#include <obexusbtransportinfo.h>
+#include "ObexUsbTransportController.h"
+#include "usbconn.h"
+#include "logger.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "USB");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ObexUsbTC");
+enum
+ {
+ KUsbTCError = 0,
+ };
+#endif
+
+
+/**
+Constructs a CObexUsbTransportController object
+
+@param aTransportInfo Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo.
+
+@return A new CObexUsbTransportController object
+*/
+CObexUsbTransportController* CObexUsbTransportController::NewL(TObexTransportInfo& aTransportInfo)
+ {
+ CObexUsbTransportController* self = new(ELeave) CObexUsbTransportController;
+ CleanupStack::PushL(self);
+ self->ConstructL(aTransportInfo);
+ CleanupStack::Pop(self);
+ return(self);
+ }
+
+/**
+CObexUsbTransportController constructor.
+*/
+CObexUsbTransportController::CObexUsbTransportController()
+ :CObexTransportControllerBase()
+ {
+ }
+
+
+/**
+2nd Phase Construction.
+
+@param aTransportInfo Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo.
+*/
+void CObexUsbTransportController::ConstructL(TObexTransportInfo& aTransportInfo)
+ {
+ //Note: The CObexUsbConnector will determine if UsbTransportInfo has type TObexUsbTransportInfo or TObexUsbV2TransportInfo.
+ //CObexUsbTransportController does not need to know
+ TObexUsbTransportInfo& usbTransportInfo = static_cast<TObexUsbTransportInfo&>(aTransportInfo);
+
+ iConnector = CObexUsbConnector::NewL(*this, usbTransportInfo);
+ iTransportInfo = new(ELeave) TObexUsbTransportInfo;
+ Mem::Copy(iTransportInfo, &usbTransportInfo, sizeof(TObexUsbTransportInfo));
+ }
+
+/**
+CObexUsbTransportController destructor
+*/
+CObexUsbTransportController::~CObexUsbTransportController()
+ {
+ }
+
+
+/**
+Gets the socket associated with the connector and asks the socket for its remote name.
+
+@param aAddr Reference to a TSockAddr. Since this is the USB transport controller, there is no socket
+ address to return, so the reference is zeroed.
+*/
+void CObexUsbTransportController::DoRemoteAddr(TSockAddr& aAddr)
+ {
+ Mem::FillZ(&aAddr, sizeof(TSockAddr));
+ }
+
+
+/**
+Used indirectly by CObex::ControlledTransportDown() to determine whether the transport
+can be forced down, or if the connection should just be cancelled and cleaned up.
+
+@return The USB transport cannot be restarted, so should not be forced down. Hence return EFalse
+*/
+TBool CObexUsbTransportController::DoIsTransportRestartable() const
+ {
+ return EFalse;
+ }
+
+
+/**
+Returns the receive packet data limit
+
+@return The receive packet data limit
+*/
+TUint16 CObexUsbTransportController::GetReceivePacketDataLimit()
+ {
+ LOG_FUNC
+
+ // Set initial "software throttle" for packets (how big OBEX says they are)
+ __ASSERT_DEBUG(iTransportInfo, PANIC(KPanicCat, KUsbTCError));
+ TUint16 receivePacketDataLimit = iTransportInfo->iReceiveMtu;
+ return receivePacketDataLimit;
+ }
+
+
+/*
+Creates the reader and writer and constructs the packets
+Called via CObexTransportControllerBase::DoTransportUp
+
+@param aInfo Connection info to pass to active reader/writer classes
+*/
+void CObexUsbTransportController::NewTransportL(TObexConnectionInfo& aInfo)
+ {
+ __ASSERT_DEBUG((aInfo.iSocketType == TObexConnectionInfo::EUsbStream), PANIC(KPanicCat, KUsbTCError));
+
+ //Get the RDevUsbcClient to pass to the active reader/writer
+ RDevUsbcClient* usbc = reinterpret_cast<CObexUsbConnector*>(iConnector)->TransportObject();
+
+ // Get the packet size of the link
+ TInt pktSize = reinterpret_cast<CObexUsbConnector*>(iConnector)->GetTransportPacketSize();
+
+ //CObexUsbActiveReader(MObexTransportNotify* aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo);
+ iActiveReader = CObexUsbActiveReader::NewL(*this, *usbc, aInfo);
+ //CObexUsbActiveWriter(MObexTransportNotify* aOwner, RDevUsbcClient& aUsb, TObexConnectionInfo& aInfo);
+ iActiveWriter = CObexUsbActiveWriter::NewL(*this, *usbc, aInfo, pktSize);
+
+ iConnectionInfo = aInfo;
+ }
+
+
+/**
+Implements MObexTransportNotify
+Process the received packet.
+
+@param aPacket A reference to a CObexPacket
+*/
+void CObexUsbTransportController::DoProcess(CObexPacket &aPacket)
+ {
+ CObexTransportControllerBase::DoProcess(aPacket);
+ }
+
+
+/*
+Implements MObexTransportNotify
+Calls base implementation
+Future proofing against BC breaks
+
+@param aError The error value
+*/
+void CObexUsbTransportController::DoError(TInt aError)
+ {
+ CObexTransportControllerBase::DoError(aError);
+ }
+
+
+/*
+Implements MObexTransportNotify
+Calls base implementation
+Future proofing against BC breaks
+
+@param aInfo Connection info to pass to active reader/writer classes
+*/
+void CObexUsbTransportController::DoTransportUp(TObexConnectionInfo& aInfo)
+ {
+ CObexTransportControllerBase::DoTransportUp(aInfo);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/obex/obexprotocol/obexusbtransport/src/usbconn.cpp Tue Oct 19 11:00:12 2010 +0800
@@ -0,0 +1,1321 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#include <obexusbtransportinfo.h>
+#include "usbconn.h"
+#include <obex/transport/obexconnector.h>
+#include "logger.h"
+#include "obexusbfaults.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "USB");
+#endif
+
+#ifdef _DEBUG
+_LIT(KPanicCat, "ObexUsbHandler");
+#endif
+
+
+//
+
+/**
+CObexUsbActiveWriter factory function
+
+@param aTransport Reference to a CObexUsbTransportController object. Required for a call to the CObexUsbActiveReader
+@param aOwner Reference to a MObexTransportNotify object
+@param aUsb Reference to a RDevUsbcClient object
+@param aInfo Reference to a TObexConnectionInfo object
+@param aPacketSize The size of packets used on the underlying link, dependent on High Speed mode.
+@return Ownership of a new CObexUsbActiveWriter.
+*/
+CObexUsbActiveWriter* CObexUsbActiveWriter::NewL(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb,
+ TObexConnectionInfo& aInfo, TInt aPacketSize)
+ {
+ CObexUsbActiveWriter* self = new(ELeave) CObexUsbActiveWriter(aOwner, aUsb, aInfo, aPacketSize);
+ CleanupStack::PushL(self);
+ self->BaseConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+CObexUsbActiveWriter constructor
+
+@param aTransport Reference to a CObexUsbTransportController object. Required for a call to the CObexUsbActiveReader
+@param aOwner Reference to a MObexTransportNotify object
+@param aUsb Reference to a RDevUsbcClient object
+@param aInfo Reference to a TObexConnectionInfo object
+@param aPacketSize The size of packets used on the underlying link, dependent on High Speed mode.
+*/
+CObexUsbActiveWriter::CObexUsbActiveWriter(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb,
+ TObexConnectionInfo& aInfo, TInt aPacketSize)
+: CObexWriterBase(EPriorityHigh, aOwner, aInfo),
+ iUsb(aUsb), iPacketSize(aPacketSize)
+ {
+ }
+
+
+/**
+CObexUsbActiveWriter destructor.
+*/
+CObexUsbActiveWriter::~CObexUsbActiveWriter()
+ {
+ LOG_FUNC
+
+ Cancel();
+ }
+
+
+/**
+Start actual transfer. May be called several times by CObexActiveRW::RunL.
+Queues a write on USB endpoint.
+*/
+void CObexUsbActiveWriter::DoTransfer()
+ {
+ LOG_FUNC
+ LOG1(_L("CObexUsbActiveWriter::DoTransfer [Length=%d]"),iLocation.Length());
+
+ iLocation.SetMax();
+ iUsb.Write(iStatus, KTransmitEndpoint, iLocation, iLocation.Length(), ETrue);
+ SetActive();
+ }
+
+
+/**
+Cancels an outstanding write.
+*/
+void CObexUsbActiveWriter::DoCancel()
+ {
+ LOG_FUNC
+
+ //Only cancel the write if there's more than 1 packet left to write.
+ //This restriction is imposed to prevent the SUCCESS response being
+ //cancelled when an ObexServer is handling a disconnect and bringing
+ //the transport down.
+ if(Remaining() > iPacketSize)
+ {
+ iUsb.WriteCancel(KTransmitEndpoint);
+ }
+ }
+
+
+//
+
+/**
+CObexUsbActiveReader factory function
+
+@param aOwner Reference to a MObexTransportNotify object
+@param aUsb Reference to a RDevUsbcClient object
+@param aInfo Reference to a TObexConnectionInfo object
+@return Ownership of a new CObexUsbActiveWriter.
+*/
+CObexUsbActiveReader* CObexUsbActiveReader::NewL(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb,
+ TObexConnectionInfo& aInfo)
+ {
+ CObexUsbActiveReader* self = new(ELeave) CObexUsbActiveReader(aOwner, aUsb, aInfo);
+ CleanupStack::PushL(self);
+ self->BaseConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+CObexUsbActiveReader constructor
+
+@param aOwner Reference to a MObexTransportNotify object
+@param aUsb Reference to a RDevUsbcClient object
+@param aInfo Reference to a TObexConnectionInfo object
+*/
+CObexUsbActiveReader::CObexUsbActiveReader(MObexTransportNotify& aOwner, RDevUsbcClient& aUsb,
+ TObexConnectionInfo& aInfo)
+: CObexReaderBase(EPriorityStandard, aOwner, aInfo), iUsb(aUsb)
+ {
+ }
+
+
+/**
+CObexUsbActiveReader destructor.
+*/
+CObexUsbActiveReader::~CObexUsbActiveReader()
+ {
+ LOG_FUNC
+
+ Cancel();
+ }
+
+
+/**
+Start actual transfer. May be called several times by CObexActiveRW::RunL.
+Queues a read on USB endpoint.
+*/
+void CObexUsbActiveReader::DoTransfer()
+ {
+ LOG_FUNC
+ LOG1(_L("CObexUsbActiveReader::DoTransfer [maxLength=%d]"),iLocation.MaxLength());
+
+ iUsb.ReadUntilShort(iStatus, KReceiveEndpoint, iLocation);
+ SetActive();
+ }
+
+
+/**
+Cancels an outstanding read,
+ */
+void CObexUsbActiveReader::DoCancel()
+ {
+ FLOG(_L("CObexUsbActiveReader::DoCancel"));
+
+ iUsb.ReadCancel(KReceiveEndpoint);
+ }
+
+
+/**
+Return the maximum packet size
+@return TInt the maximum packet size for this transport
+*/
+TInt CObexUsbActiveReader::GetMaxPacketSize()
+ {
+ LOG_FUNC
+
+ return GetObexPacketDataLimit();
+ }
+
+
+/**
+Returns a initial packet size when the packet size of iPacket is not know. This is used
+when determining the remaining bytes to be read.
+@return TInt the initial packet size
+*/
+TInt CObexUsbActiveReader::GetInitialPacketSize ()
+ {
+ LOG_FUNC
+
+ return GetObexPacketBufferSize();
+ }
+//
+
+/**
+CObexUsbConnector constructor.
+*/
+CObexUsbConnector::CObexUsbConnector(MObexTransportNotify& aObserver, TObexUsbTransportInfo& aUsbTransportInfo)
+ : CObexConnector(aObserver),
+ iObexTransportInfo(aUsbTransportInfo),
+ iMode(EDefaultClient)
+ {
+ LOG_FUNC
+ // Note iObexTransportInfo reference is only kept so that it can be used in the ConstructL
+ // It may not be safe to use this variables outside of the construction phases
+ }
+
+
+/*
+Returns an instance of CObexUsbConnector
+
+@param aController Reference to a MObexTransportNotify object (the CObexUsbTransportController that owns this)
+@param aTransportInfo Reference to a TObexUsbTransportInfo object containing the transport information
+
+@return A pointer to a CObexUsbConnector object
+*/
+CObexUsbConnector* CObexUsbConnector::NewL(MObexTransportNotify& aController, TObexUsbTransportInfo& aTransportInfo)
+ {
+ CObexUsbConnector* self = new(ELeave) CObexUsbConnector(aController, aTransportInfo);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return(self);
+ }
+
+
+/**
+Second phase construction.
+*/
+void CObexUsbConnector::ConstructL()
+ {
+ LOG_FUNC
+
+ OpenUsbL(0);
+
+ FLOG(_L("USB opened"));
+
+ iHandler = CObexUsbHandler::NewL(iObexTransportInfo, *this, iUsb);
+ iCallback = new(ELeave) CAsyncCallBack(EPriorityHigh);
+ iStaller = CObexUsbStaller::NewL(iUsb, *this);
+ iHandler->Start();
+
+ BaseConstructL();
+ }
+
+
+/**
+CObexUsbConnector destructor. Releases endpoint and closes USB object if we have an open connection.
+*/
+CObexUsbConnector::~CObexUsbConnector()
+ {
+ LOG_FUNC
+
+ delete iCallback;
+ delete iHandler;
+ delete iStaller;
+
+ if (iUsb.Handle())
+ {
+ iUsb.Close();
+ }
+ }
+
+
+/**
+Attempt to open a client-type connection.
+This will succeed if the USB host has already opened a connection to us
+*/
+void CObexUsbConnector::ConnectL()
+ {
+ LOG_FUNC
+
+ if (iMode == EServer)
+ {
+ // Already performed a server-type connect, so can't act as a
+ // client as well.
+ FLOG(_L(" -- In server mode, give up"));
+ LEAVEIFERRORL(KErrNotSupported);
+ }
+
+
+ FLOG(_L(" -- Not in server mode"));
+
+ iMode = EClient;
+ if (iTransportLinkAvailable)
+ {
+ FLOG(_L(" -- Link available, set a callback"));
+
+ TCallBack callback(LinkUp, this);
+ iCallback->Set(callback);
+ iCallback->CallBack();
+ iConnectRequested = ETrue;
+ }
+ else
+ {
+ FLOG(_L(" -- No link available, set a callback"));
+
+ TCallBack callback(NoDevice, this);
+ iCallback->Set(callback);
+ iCallback->CallBack();
+ }
+ }
+
+
+/*
+@param aConn A pointer to a connector object. Will be cast to CObexUsbConnector
+
+@return KErrNone
+*/
+TInt CObexUsbConnector::LinkUp(TAny* aConn)
+ {
+ FLOG(_L("CObexUsbConnector::LinkUp"));
+
+ reinterpret_cast<CObexUsbConnector*>(aConn)->SignalUp();
+ return KErrNone;
+ }
+
+
+/*
+@param aConn A pointer to a connector object. Will be cast to CObexUsbConnector
+
+@return KErrNone
+*/
+TInt CObexUsbConnector::NoDevice(TAny* aConn)
+ {
+ FLOG(_L("CObexUsbConnector::NoDevice"));
+
+ reinterpret_cast<CObexUsbConnector*>(aConn)->SignalDown(KErrIrObexClientPeerDoesNotHaveObex);
+ return KErrNone;
+ }
+
+
+/**
+Cancel an active connection attempt. This is unlikely to succeed, as a client
+connection over USB will complete almost immediately.
+*/
+void CObexUsbConnector::CancelConnect()
+ {
+ LOG_FUNC
+
+ if (iMode == EClient)
+ {
+ iCallback->Cancel();
+ }
+
+ iConnectRequested = EFalse;
+ }
+
+
+/**
+Start listening for a connection to us.
+*/
+void CObexUsbConnector::AcceptL()
+ {
+ LOG_FUNC
+
+ if (iMode == EClient)
+ {
+ // Already carried out a client side connection. Therefore we
+ // can't be a server as well.
+ FLOG(_L(" -- In client mode, give up"));
+
+ LEAVEIFERRORL(KErrNotSupported);
+ }
+
+ FLOG(_L(" -- Not in client mode"));
+
+ iMode = EServer;
+ if (iTransportLinkAvailable)
+ {
+ FLOG(_L(" -- Transport link currently available, set a callback"));
+
+ TCallBack callback(LinkUp, this);
+ iCallback->Set(callback);
+ iCallback->CallBack();
+ }
+ else
+ {
+ FLOG(_L(" -- No link available, wait for one"));
+
+ iWaitingForLink = ETrue;
+ }
+ }
+
+/**
+Stop listening for connections.
+*/
+void CObexUsbConnector::CancelAccept()
+ {
+ LOG_FUNC
+
+ if (iMode == EServer)
+ {
+ iWaitingForLink = EFalse;
+ iCallback->Cancel();
+ }
+ }
+
+
+/**
+Called to indicate transport layer has come up.
+*/
+void CObexUsbConnector::TransportUp()
+ {
+ LOG_FUNC
+
+ SetTransportPacketSize();
+
+ iTransportLinkAvailable = ETrue;
+
+ if ((iMode == EServer) && (iWaitingForLink))
+ {
+ FLOG(_L(" -- Signalling link available"));
+
+ iWaitingForLink = EFalse;
+ SignalUp();
+ }
+ }
+
+/**
+Called to indicate transport layer has gone down.
+
+@param aErr Any error code associated with disconnection. Defaults to KErrDisconnected.
+*/
+void CObexUsbConnector::TransportDown(TInt aErr)
+ {
+ LOG_FUNC
+
+ ResetTransportPacketSize();
+
+ iStaller->Cancel();
+
+ iTransportLinkAvailable = EFalse;
+
+ if (iMode == EServer)
+ {
+ FLOG(_L(" -- In server mode, signal link down"));
+
+ SignalDown(aErr);
+ }
+ else
+ {
+ FLOG(_L(" -- In client mode"));
+
+ // Client or default client state
+ if (iConnectRequested)
+ {
+ FLOG(_L(" -- Outstanding client connection. Signal link down"));
+
+ iConnectRequested = EFalse;
+ SignalDown(aErr);
+ }
+ }
+ }
+
+/**
+Signals to the transport controller that the transport is up
+*/
+void CObexUsbConnector::SignalUp()
+ {
+ LOG_FUNC
+
+ // Indicate transport now up
+ TObexConnectionInfo sockinfo;
+ sockinfo.iMaxRecvSize = 0; // set these to zero as we can't find them out
+ sockinfo.iMaxSendSize = 0; // and they are not used
+ sockinfo.iSocketType = TObexConnectionInfo::EUsbStream;
+ Observer().TransportUp(sockinfo);
+ }
+
+
+/**
+Signals (with an error code) to the transport controller that the transport has gone down
+*/
+void CObexUsbConnector::SignalDown(TInt aErr)
+ {
+ FLOG(_L("CObexUsbConnector::SignalDown"));
+
+ Observer().Error(aErr);
+ }
+
+
+/**
+The Obex server running over USB is not able to bring the transport
+down itself. It will only delete the transport object when an error
+has occurred (such as the link being brought down) and hence the
+transport is no longer valid.
+
+@return ETrue
+*/
+TBool CObexUsbConnector::BringTransportDown()
+{
+ // This cancel function needs to be called here because it
+ // doesn't get called anywhere else. Bluetooth and IrDA rely
+ // on the socket shutdown to cancel the accept.
+ CancelAccept();
+ return ETrue;
+}
+
+
+/**
+Return the transport layer object for use by USB transport objects
+
+@return Pointer to the USB transport layer object
+*/
+RDevUsbcClient* CObexUsbConnector::TransportObject()
+ {
+ return &iUsb;
+ }
+
+
+/**
+Sets a bus stall condition on the IN endpoint. This will cause the USB
+host to initiate a CLEAR_FEATURE sequence, which notifies the server that the
+Obex link has been reset (equivalent to dropping the Obex level connection)
+*/
+void CObexUsbConnector::SignalTransportError()
+ {
+ LOG_FUNC
+
+ iStaller->Start();
+ iTransportLinkAvailable = EFalse;
+ iConnectRequested = EFalse;
+ }
+
+
+/**
+Stall cleared => transport available.
+This upcall has been separated from the TransportUp upcall for two
+reasons---it's called from a different class and it happens when an
+error condition has been cleared. Currently it has no special
+meaning, but this could change in future.
+*/
+void CObexUsbConnector::StallCleared()
+ {
+ LOG_FUNC
+
+ TransportUp();
+ }
+
+
+/**
+Opens USB and prepares it for use.
+
+@param aUnit According to the RDevUsbcClient documentation, this should be 0.
+*/
+void CObexUsbConnector::OpenUsbL(TInt aUnit)
+ {
+ LOG1(_L("CObexUsbConnector::OpenUsbL called for unit=%d"), aUnit);
+
+ // Load ldd
+ TInt err = User::LoadLogicalDevice(KUsbLddName);
+
+ if (err != KErrNone && err != KErrAlreadyExists)
+ {
+ LEAVEIFERRORL(err);
+ }
+
+ // Open the requested unit and initialise local state
+ LEAVEIFERRORL(iUsb.Open(aUnit));
+ }
+
+
+void CObexUsbConnector::ResetTransportPacketSize()
+ {
+ iPacketSize = 0;
+ }
+
+
+void CObexUsbConnector::SetTransportPacketSize()
+ {
+ if (iUsb.CurrentlyUsingHighSpeed())
+ {
+ iPacketSize = KMaxPacketTypeBulkHS;
+ }
+ else
+ {
+ iPacketSize = KMaxPacketTypeBulkFS;
+ }
+ }
+
+
+TInt CObexUsbConnector::GetTransportPacketSize()
+ {
+ return iPacketSize;
+ }
+
+
+//
+
+/**
+Constructs a CObexUsbHandler object
+
+@param aUsbTransportInfo Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo.
+@param aOwner Reference to a MObexUsbConnector that owns this handler
+@param aUsb Reference to a RDevUsbcClient object.
+
+@return A new CObexUsbHandler object
+*/
+CObexUsbHandler* CObexUsbHandler::NewL(TObexUsbTransportInfo& aUsbTransportInfo,
+ MObexUsbConnector& aOwner,
+ RDevUsbcClient& aUsb)
+ {
+ FLOG(_L("CObexUsbHandler::NewL"));
+
+ CObexUsbHandler* self = new (ELeave) CObexUsbHandler(aUsbTransportInfo, aOwner, aUsb);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+
+/**
+CObexUsbHandler constructor.
+
+Note that the iObexTransportInfo may not be valid outside of the construction phases
+The constructor copies out most of the information it needs into member variables
+apart from the interface string descriptor, which is used from RegInterfacesL
+
+@param aUsbTransportInfo Reference to a TObexTransportInfo object. Will be cast to TObexUsbTransportInfo.
+@param aOwner Reference to a MObexUsbConnector that owns this handler
+@param aUsb Reference to a RDevUsbcClient object.
+*/
+CObexUsbHandler::CObexUsbHandler(TObexUsbTransportInfo& aUsbTransportInfo,
+ MObexUsbConnector& aOwner,
+ RDevUsbcClient& aUsb)
+ : CActive(EPriorityStandard), iObexTransportInfo(aUsbTransportInfo),
+ iOwner(aOwner), iUsb(aUsb)
+ {
+ LOG_FUNC
+
+ CActiveScheduler::Add(this);
+
+ // Set interface performance configuration parameters
+ if (aUsbTransportInfo.iTransportName == KObexUsbProtocol)
+ // Default values if transport is normal USB - no extra bandwidth, no DMA
+ {
+ FLOG(_L("CObexUsbHandler - Using default USB protocol info"));
+ iBandwidthPriority = EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault;
+ iRequestDmaOnOutEndpoint = EFalse;
+ iRequestDmaOnInEndpoint = EFalse;
+ }
+ else if (aUsbTransportInfo.iTransportName == KObexUsbProtocolV2)
+ // If transport is extended USB take values from the protocol info
+ {
+ FLOG(_L("CObexUsbHandler - Using USB protocol extended info"));
+ TObexUsbV2TransportInfo& infoV2 = static_cast<TObexUsbV2TransportInfo&>(aUsbTransportInfo);
+ iBandwidthPriority = infoV2.iBandwidthPriority;
+ iRequestDmaOnOutEndpoint = infoV2.iDmaOnOutEndpoint;
+ iRequestDmaOnInEndpoint = infoV2.iDmaOnInEndpoint;
+ }
+ else
+ {
+ //aUsbTransportInfo.iTransportName is used to load the correct plug-in, so if this code
+ //is being executed it must have contained one of the options above. Else something
+ //has gone badly wrong.
+ __ASSERT_DEBUG(false, PANIC(KPanicCat, EUnknownUsbTransport));
+ }
+
+ LOG3(_L("CObexUsbHandler - iBandwidthPriority 0x%X, iDmaOnOutEndpoint, %d iDmaOnInEndpoint %d"),
+ iBandwidthPriority, iRequestDmaOnOutEndpoint, iRequestDmaOnInEndpoint);
+ }
+
+
+/**
+Second phase construction.
+*/
+void CObexUsbHandler::ConstructL()
+ {
+
+ // Check bandwidth priority to make sure it makes sense
+ // Reasoning is that the bitwise OR of the maximum values of IN and OUT priorities
+ // covers all the bits that can be set in iBandwidthPriority so, using this as a mask,
+ // anything set outside of this indicates that iBandwidthPriority is corrupt
+ if ( ( iBandwidthPriority & ~( EUsbcBandwidthOUTMaximum | EUsbcBandwidthINMaximum ) ) != 0 )
+ {
+ LEAVEIFERRORL(KErrArgument);
+ }
+
+ FLOG(_L("About to open USB comms interface connection"));
+
+ LEAVEIFERRORL(iUsbComms.Open(0));
+
+ FLOG(_L("Registering interfaces"));
+
+ RegInterfacesL();
+ }
+
+
+/**
+CObexUsbHandler destructor.
+*/
+CObexUsbHandler::~CObexUsbHandler()
+ {
+ LOG_FUNC
+ Cancel();
+
+ // Must release interfaces from highest alternate setting downwards
+ if (iUsb.Handle())
+ {
+#ifndef NO_ALTERNATE_USB_INTERFACE_SUPPORT
+ iUsb.ReleaseInterface(1 /*alternate setting*/);
+#endif
+ iUsb.ReleaseInterface(0 /*alternate setting*/);
+ }
+
+ if (iUsbComms.Handle())
+ {
+ iUsbComms.ReleaseInterface(0 /*alternate setting*/);
+ }
+
+ iUsbComms.Close();
+ }
+
+
+/**
+Standard active object error function.
+
+@return KErrNone because currently nothing should cause this to be called.
+*/
+TInt CObexUsbHandler::RunError(TInt /*aError*/)
+ {
+ return KErrNone;
+ }
+
+
+/**
+This function will be called upon a change in the state of the device
+(as set up in AcceptL).
+*/
+void CObexUsbHandler::RunL()
+ {
+ LOG1(_L("CObexUsbHandler::RunL called state=0x%X"), iUsbState);
+
+ if (iStatus != KErrNone)
+ {
+ LOG1(_L("CObexUsbHandler::RunL() - Error = %d"),iStatus.Int());
+
+ iTransportUp = EFalse;
+ iOwner.TransportDown(iStatus.Int());
+ return;
+ }
+
+ // Check whether the alternate setting to use or the device state has changed.
+ // We have to check the device state to handle the unplugging of the cable. We can't
+ // rely on the always-outstanding read to complete with an error, because the driver
+ // doesn't have a well-defined error code for this.
+
+ if (iUsbState & KUsbAlternateSetting)
+ {
+ iUsbState &= ~KUsbAlternateSetting;
+
+ LOG1(_L("switched to alternate setting %d"), iUsbState);
+
+ if (iUsbState == KObexAlt0)
+ {
+ // alternate setting 0 - function inactive
+ if (iTransportUp)
+ {
+ FLOG(_L("CObexUsbHandler::RunL - transport layer going down..."));
+
+ iTransportUp = EFalse;
+ iOwner.TransportDown();
+ }
+ }
+ else if (iUsbState == KObexAlt1)
+ {
+ // alternate setting 1 - function active
+ if (!iTransportUp)
+ {
+ FLOG(_L("CObexUsbHandler::RunL - transport layer coming up..."));
+
+ // Now the transport is selected, DMA can be allocated to the endpoints, if required
+ AllocateDma();
+
+ iTransportUp = ETrue;
+
+ iOwner.TransportUp();
+ }
+ }
+ else
+ {
+ FLOG(_L("WARNING: unknown setting!"));
+ }
+ }
+ else
+ {
+ TUsbcDeviceState deviceState = static_cast<TUsbcDeviceState>(iUsbState);
+
+ switch(deviceState)
+ {
+ case EUsbcDeviceStateUndefined:
+ case EUsbcDeviceStateAttached:
+ case EUsbcDeviceStatePowered:
+ case EUsbcDeviceStateDefault:
+ case EUsbcDeviceStateAddress:
+#ifdef ERRONEOUS_SUSPEND_INDICATIONS
+ // On Lubbock, we sometimes get "suspended" when the cable is unplugged.
+ case EUsbcDeviceStateSuspended:
+#endif // ERRONEOUS_SUSPEND_INDICATIONS
+ if (iTransportUp)
+ {
+ FLOG(_L("CObexUsbHandler::RunL - transport layer going down..."));
+
+ iTransportUp = EFalse;
+ iOwner.TransportDown();
+ }
+ break;
+
+#ifndef ERRONEOUS_SUSPEND_INDICATIONS
+ case EUsbcDeviceStateSuspended:
+ break;
+#endif // !ERRONEOUS_SUSPEND_INDICATIONS
+
+ case EUsbcDeviceStateConfigured:
+ // Normally, we don't do anything here, because the transport only goes up when
+ // we actually receive the alternate interface change.
+#ifdef NO_ALTERNATE_USB_INTERFACE_SUPPORT
+ if (!iTransportUp)
+ {
+ FLOG(_L("Device now configured: transport layer coming up..."));
+
+ iTransportUp = ETrue;
+
+ // DMA can be allocated to the endpoints, if required
+ // This has to be done here for no alternate interface devices
+ // as they will not receive interface change notification
+ AllocateDma();
+
+ iOwner.TransportUp();
+ }
+#endif // NO_ALTERNATE_USB_INTERFACE_SUPPORT
+ break;
+
+ default:
+ __ASSERT_DEBUG(false, PANIC(KPanicCat, EUnknownUsbState));
+ break;
+ }
+ }
+
+ // Await further notification of a state change. We may have called Error(), which
+ // would already have set this notification request.
+ if (!IsActive())
+ {
+ iUsb.AlternateDeviceStatusNotify(iStatus, iUsbState);
+ SetActive();
+ }
+
+ FLOG(_L("CObexUsbHandler::RunL finished"));
+ }
+
+
+/**
+Standard active object cancellation function.
+*/
+void CObexUsbHandler::DoCancel()
+ {
+ LOG_FUNC
+
+ iUsb.AlternateDeviceStatusNotifyCancel();
+ }
+
+
+/**
+Registers the required comms and data interfaces.
+*/
+void CObexUsbHandler::RegInterfacesL()
+ {
+ LOG_FUNC
+
+ // Setup a CDC Communication Class interface
+ TUsbcInterfaceInfoBuf ifc;
+
+ // Extract the interface string from the transport info structure we were
+ // passed on construction. This isn't const because the SetInterface API
+ // requires it not to be.
+ // This is the only point where iObexTransportInfo is used directly
+ // Do not use iObexTransportInfo outside of construction phases
+ TPtrC string(iObexTransportInfo.iInterfaceStringDescriptor);
+
+ LOG1(_L("Using interface string \"%S\""), &string);
+
+ ifc().iString = &string;
+ ifc().iClass.iClassNum = KObexClassNumber;
+ ifc().iClass.iSubClassNum = KObexSubClassNumber;
+ ifc().iClass.iProtocolNum = KObexProtocolNumber;
+ ifc().iTotalEndpointsUsed = 0;
+
+ // Indicate that this interface does not expect any control transfers
+ // from EP0.
+ ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease;
+
+ FLOG(_L("CObexUsbListeningConnector::RegInterfacesL - setting comms interface"));
+
+ TInt err = iUsbComms.SetInterface(0, ifc);
+
+ if (err != KErrNone)
+ {
+ LOG1(_L("SetInterface failed with error %d"), err);
+ LEAVEIFERRORL(err);
+ }
+
+ // Get the interface number for later
+ TInt intDescSize;
+ err = iUsbComms.GetInterfaceDescriptorSize(0,intDescSize);
+ if(err != KErrNone)
+ {
+ LOG1(_L("Failed to get interface descriptor size. Err = %d"),err);
+ intDescSize = KObexDefaultInterfaceDescriptorLength; //Default is 100
+ }
+ HBufC8* interfaceDescriptor;
+ interfaceDescriptor = HBufC8::NewLC(intDescSize);
+ TPtr8 pIntDesc = interfaceDescriptor->Des();
+ iUsbComms.GetInterfaceDescriptor(0, pIntDesc);
+ TUint8 obexIntNo = interfaceDescriptor->Ptr()[2];
+ CleanupStack::PopAndDestroy();
+
+ TBuf8<KObexInterfaceDescriptorBlockLength> desc;
+
+ // Comms Class Header Functional Descriptor
+
+ desc.Append(KObexFunctionalDescriptorLength);
+ desc.Append(KUsbDescType_CS_Interface);
+ desc.Append(KHeaderFunctionalDescriptor);
+ desc.Append(KCdcVersionNumber[0]);
+ desc.Append(KCdcVersionNumber[1]);
+
+ // Obex Functional Descriptor
+
+ desc.Append(KObexFunctionalDescriptorLength);
+ desc.Append(KUsbDescType_CS_Interface);
+ desc.Append(KObexFunctionalDescriptor);
+ desc.Append(KWmcdcVersionNumber[0]);
+ desc.Append(KWmcdcVersionNumber[1]);
+
+ // Union Functional Descriptor
+
+ desc.Append(KObexFunctionalDescriptorLength);
+ desc.Append(KUsbDescType_CS_Interface);
+ desc.Append(KUnionFunctionalDescriptor);
+ desc.Append(obexIntNo);
+ TInt dataInt = obexIntNo + 1;
+ desc.Append(static_cast<TUint8>(dataInt));
+
+ err = iUsbComms.SetCSInterfaceDescriptorBlock(0, desc);
+ if (err != KErrNone)
+ {
+ LOG1(_L("SetCSInterfaceDescriptorBlock failed with error %d"), err);
+ LEAVEIFERRORL(err);
+ }
+
+ // Setup CDC Data Class interfaces
+
+ // Only set the "function inactive" interface (alternate setting 0)
+ // if the device can support alternate interfaces
+#ifndef NO_ALTERNATE_USB_INTERFACE_SUPPORT
+ TUsbcInterfaceInfoBuf dataifc;
+
+ dataifc().iString = NULL;
+ dataifc().iClass.iClassNum = KObexDataClass;
+ dataifc().iClass.iSubClassNum = KObexDataSubClass;
+ dataifc().iClass.iProtocolNum = 0;
+ dataifc().iTotalEndpointsUsed = 0;
+
+ // Indicate that this interface does not expect any control transfers
+ // from EP0.
+ dataifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease;
+
+ FLOG(_L("Setting data class interface (alt setting 0"));
+
+ err = iUsb.SetInterface(0 /*alternate setting*/, dataifc, iBandwidthPriority);
+ if (err != KErrNone)
+ {
+ LOG1(_L("Cannot set data interface (alternate setting 0): error %d"), err);
+ LEAVEIFERRORL(err);
+ }
+
+ // If anything below this point leaves, make sure this alternate setting
+ // gets released.
+ CleanupStack::PushL(TCleanupItem(CleanupReleaseInterface0, &iUsb));
+#endif // NO_ALTERNATE_USB_INTERFACE_SUPPORT
+
+ // Check the device has enough endpoints for the "function active" data interface
+ TUsbDeviceCaps dCaps;
+ LEAVEIFERRORL(iUsb.DeviceCaps(dCaps));
+
+ TInt n = dCaps().iTotalEndpoints;
+ if (n < KObexMinNumEndpoints)
+ {
+ LEAVEIFERRORL(KErrOverflow);
+ }
+
+ // Use the hardware's HS capability to determine maximum bulk transfer packet size
+ TInt maxPacketSize = (dCaps().iHighSpeed) ? KMaxPacketTypeBulkHS : KMaxPacketTypeBulkFS;
+
+
+ // Get information on the available endpoints from the driver
+ TUsbcEndpointData data[KUsbcMaxEndpoints];
+ TPtr8 dataptr(REINTERPRET_CAST(TUint8*, data), sizeof(data), sizeof(data));
+ LEAVEIFERRORL(iUsb.EndpointCaps(dataptr));
+
+ // Check to see if there are suitably capable IN and OUT endpoints available
+ // and fill dataifc2 structure accordingly.
+ //
+ // NOTE: The order the iEndpointData array is filled matches the order used for the
+ // virtual endpoint numbers KTransmitEndpoint and KReceiveEndpoint - so change with caution!
+ //
+ // The virtual endpoint numbers are 1-based, whereas the iEndpointData array is 0 based
+ // hence the subtraction in the array indices
+ //
+ // NOTE: IN and OUT refer to the host so in this case:
+ // IN => device to PC = KTransmitEndpoint
+ // OUT => PC to device = KReceiveEndpoint
+ TUsbcInterfaceInfoBuf dataifc2;
+ TBool foundIn = EFalse;
+ TBool foundOut = EFalse;
+ for (TInt i = 0; !(foundIn && foundOut) && i < n; i++)
+ {
+ const TUsbcEndpointCaps* caps = &data[i].iCaps;
+ if (data[i].iInUse)
+ {
+ continue;
+ }
+
+ const TUint KBulkInFlags = KUsbEpTypeBulk | KUsbEpDirIn;
+ const TUint KBulkOutFlags = KUsbEpTypeBulk | KUsbEpDirOut;
+
+ if (!foundIn && (caps->iTypesAndDir & KBulkInFlags) == KBulkInFlags)
+ {
+ dataifc2().iEndpointData[KTransmitEndpoint - 1].iType = KUsbEpTypeBulk;
+ dataifc2().iEndpointData[KTransmitEndpoint - 1].iDir = KUsbEpDirIn;
+ TInt maxSize = caps->MaxPacketSize();
+ if (maxSize > maxPacketSize)
+ {
+ maxSize = maxPacketSize;
+ }
+ dataifc2().iEndpointData[KTransmitEndpoint - 1].iSize = maxSize;
+
+ // Allocate dma if requested and the device support resource allocation scheme version 2
+ // for resource allocation scheme version1, refer to AllocateDma()
+ if (iRequestDmaOnInEndpoint &&
+ ((dCaps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0))
+ {
+ dataifc2().iEndpointData[KTransmitEndpoint - 1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DMA;
+ }
+
+ foundIn = ETrue;
+ }
+ else if (!foundOut && (caps->iTypesAndDir & KBulkOutFlags) == KBulkOutFlags)
+ {
+ dataifc2().iEndpointData[KReceiveEndpoint - 1].iType = KUsbEpTypeBulk;
+ dataifc2().iEndpointData[KReceiveEndpoint - 1].iDir = KUsbEpDirOut;
+ TInt maxSize = caps->MaxPacketSize();
+ if (maxSize > maxPacketSize)
+ {
+ maxSize = maxPacketSize;
+ }
+ dataifc2().iEndpointData[KReceiveEndpoint - 1].iSize = maxSize;
+
+ //Allocate dma here if requested and the device support resource allocation scheme version 2
+ // for resource allocation scheme version1, refer to AllocateDma()
+ if (iRequestDmaOnOutEndpoint &&
+ ((dCaps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0))
+ {
+ dataifc2().iEndpointData[KReceiveEndpoint - 1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DMA;
+ }
+
+ foundOut = ETrue;
+ }
+ }
+
+ if (!(foundIn && foundOut))
+ {
+ LEAVEIFERRORL(KErrHardwareNotAvailable);
+ }
+
+ // Set the active interface.
+ dataifc2().iString = NULL;
+ dataifc2().iClass.iClassNum = KObexDataClass;
+ dataifc2().iClass.iSubClassNum = KObexDataSubClass;
+ dataifc2().iClass.iProtocolNum = 0;
+ dataifc2().iTotalEndpointsUsed = KObexTotalEndpoints;
+
+ // Indicate that this interface does not expect any control transfers
+ // from EP0.
+ dataifc2().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease;
+
+#ifdef NO_ALTERNATE_USB_INTERFACE_SUPPORT
+ // For devices that don't suport alternate interfaces, have to place the "function active"
+ // interface at alternate setting 0, although the CDC specification says if should be alternate setting 1
+ FLOG(_L("Setting data class interface (no alternate interface support)"));
+
+ err = iUsb.SetInterface(0 /*alternate setting*/, dataifc2, iBandwidthPriority);
+
+ if (err != KErrNone)
+ {
+ //FTRACE(FPrint(_L("Cannot set data interface (no alternate interface support): error %d"), err));
+ LOG1(_L("Cannot set data interface (no alternate interface support): error %d"), err);
+ LEAVEIFERRORL(err);
+ }
+#else
+ FLOG(_L("Setting data class interface (alternate setting 1)"));
+
+ err = iUsb.SetInterface(1 /*alternate setting*/, dataifc2, iBandwidthPriority);
+
+ if (err != KErrNone)
+ {
+ //FTRACE(FPrint(_L("Cannot set data interface (alternate setting 1): error %d"), err));
+ LOG1(_L("Cannot set data interface (alternate setting 1): error %d"), err);
+ LEAVEIFERRORL(err);
+ }
+
+ CleanupStack::Pop(); // ReleaseInterface0
+#endif
+
+ FLOG(_L("CObexUsbHandler::RegInterfacesL - finished."));
+ }
+
+
+/**
+Utility function which releases the first alternate setting of the specified
+interface. Used when setting up Obex interfaces.
+
+@param aInterface The interface to release
+*/
+void CObexUsbHandler::CleanupReleaseInterface0(TAny* aInterface)
+ {
+ reinterpret_cast<RDevUsbcClient*>(aInterface)->ReleaseInterface(0 /*alternate setting*/);
+ }
+
+
+/**
+Accept an incoming connection.
+*/
+void CObexUsbHandler::Start()
+ {
+ LOG_FUNC
+
+ // Await notification of a state change (this is like waiting for a connect...).
+ iUsb.AlternateDeviceStatusNotify(iStatus, iUsbState);
+ SetActive();
+ }
+
+
+/**
+Utility function to allocate DMA to the bulk endpoints - if they have been requested
+This function is called during a connect, once the device is configured,
+so if the allocations fail it wont complain in release builds but debug builds will
+panic with either EDmaAllocationFailedEndpointIn or EDmaAllocationFailedEndpointOut.
+*/
+void CObexUsbHandler::AllocateDma()
+ {
+ LOG_FUNC
+
+ TUsbDeviceCaps dCaps;
+ iUsb.DeviceCaps(dCaps);
+ if ((dCaps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0)
+ {
+ // for resource allocation version2, refer to CObexUsbHandler::RegInterfacesL()
+ return;
+ }
+
+ if (iRequestDmaOnInEndpoint)
+ {
+ TInt err = iUsb.AllocateEndpointResource(KTransmitEndpoint, EUsbcEndpointResourceDMA);
+ // The following log message is checked for in the test code - change with caution!
+ LOG1(_L("IN Endpoint DMA resource allocation result %d"), err);
+ (void)err; // to stop compilers complaining about unused variables
+ }
+
+ if (iRequestDmaOnOutEndpoint)
+ {
+ TInt err = iUsb.AllocateEndpointResource(KReceiveEndpoint, EUsbcEndpointResourceDMA);
+ // The following log message is checked for in the test code - change with caution!
+ LOG1(_L("OUT Endpoint DMA resource allocation result %d"), err);
+ (void)err; // to stop compilers complaining about unused variables
+ }
+ }
+
+
+//
+
+/**
+Constructs a CObexUsbStaller object
+
+@param aUsb Reference to a RDevUsbcClient object.
+@param aOwner Reference to a MObexUsbConnector that owns this handler
+
+@return A new CObexUsbStaller object
+*/
+CObexUsbStaller* CObexUsbStaller::NewL(RDevUsbcClient& aUsb, MObexUsbConnector& aOwner)
+ {
+ CObexUsbStaller* self = new(ELeave) CObexUsbStaller(aUsb, aOwner);
+ return self;
+ }
+
+/**
+CObexUsbStaller constructor.
+
+@param aUsb Reference to a RDevUsbcClient object.
+@param aOwner Reference to a MObexUsbConnector that owns this handler
+*/
+CObexUsbStaller::CObexUsbStaller(RDevUsbcClient& aUsb, MObexUsbConnector& aOwner)
+ : CActive(EPriorityStandard), iUsb(aUsb), iOwner(aOwner)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+
+/**
+CObexUsbStaller destructor.
+*/
+CObexUsbStaller::~CObexUsbStaller()
+ {
+ Cancel();
+ }
+
+
+/**
+Starts the staller
+*/
+void CObexUsbStaller::Start()
+ {
+ LOG_FUNC
+
+ if (!IsActive())
+ {
+ FLOG(_L("Halting transmit endpoint..."));
+ iUsb.HaltEndpoint(KTransmitEndpoint);
+ iUsb.EndpointStatusNotify(iStatus, iEndpointStatus);
+ SetActive();
+ }
+ }
+
+
+/**
+Called when the transmit endpoint has changed state
+*/
+void CObexUsbStaller::RunL()
+ {
+ LOG_FUNC
+
+ TEndpointState endpointState;
+ iUsb.EndpointStatus(KTransmitEndpoint, endpointState);
+#ifdef __FLOG_ACTIVE
+ switch (endpointState)
+ {
+ case EEndpointStateNotStalled:
+ {
+ FLOG(_L("Receive endpoint not stalled"));
+ break;
+ }
+ case EEndpointStateStalled:
+ {
+ FLOG(_L("Receive endpoint stalled"));
+ break;
+ }
+ case EEndpointStateUnknown:
+ {
+ FLOG(_L("Receive endpoint unknown state"));
+ break;
+ }
+ }
+#endif
+ if (endpointState == EEndpointStateNotStalled)
+ {
+ LOG1(_L("CObexUsbStallWatcher::RunL -- endpoint no longer stalled (0x%08x)"), iEndpointStatus);
+ iOwner.StallCleared();
+ }
+ else
+ {
+ LOG1(_L("CObexUsbStallWatcher::RunL -- endpoint still stalled (0x%08x)"), iEndpointStatus);
+ iUsb.EndpointStatusNotify(iStatus, iEndpointStatus);
+ SetActive();
+ }
+ }
+
+
+/**
+Standard active object error function.
+
+@return KErrNone because currently nothing should cause this to be called.
+*/
+TInt CObexUsbStaller::RunError(TInt /*aError*/)
+ {
+ LOG_FUNC
+
+ return KErrNone;
+ }
+
+
+/**
+Standard active object cancellation function.
+*/
+void CObexUsbStaller::DoCancel()
+ {
+ FLOG(_L("CObexUsbStaller -- Cancelling status notification"));
+ iUsb.EndpointStatusNotifyCancel();
+ }
+
--- a/package_definition.xml Fri Oct 15 15:05:57 2010 +0800
+++ b/package_definition.xml Tue Oct 19 11:00:12 2010 +0800
@@ -86,5 +86,13 @@
<unit bldFile="backupandrestore/backuptest/group" mrp="backupandrestore/backuptest/group/connectivity_backuptest.mrp"/>
</component>
</collection>
+ <collection id="obex" name="OBEX" level="generic">
+ <component id="obexprotocol" name="OBEX Protocol" introduced="9.1" purpose="optional" filter="s60">
+ <unit bldFile="obex/obexprotocol/group" mrp="obex/obexprotocol/group/obex.mrp"/>
+ </component>
+ <component id="obexextensionapi" name="OBEX Extension API" introduced="9.2" purpose="optional" filter="s60">
+ <unit bldFile="obex/obexextensionapi/group" mrp="obex/obexextensionapi/group/obex_extensionapis.mrp"/>
+ </component>
+ </collection>
</package>
</SystemDefinition>