upnpavcontrolpoint/upnpaccessplugin/src/upnpaccess.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /** @file
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies  this distribution, and is available 
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implements remote access plugin API - loopback to File Server
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "upnpaccess.h"
       
    21 #include "upnpmdebug.h"
       
    22 
       
    23 #include <e32std.h>
       
    24 #include <ecom/implementationproxy.h>
       
    25 
       
    26 // ============================= LOCAL FUNCTIONS ===============================
       
    27 
       
    28 // Map the interface UIDs to implementation factory functions
       
    29 const TImplementationProxy ImplementationTable[] = 
       
    30     {
       
    31         {{0x101F9779}, (TProxyNewLPtr)CUpnpAccess::NewL}
       
    32     };
       
    33 
       
    34 // ----------------------------------------------------------------------------
       
    35 // ImplementationGroupProxy
       
    36 // Exported proxy for instantiation method resolution
       
    37 // ----------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C const TImplementationProxy*
       
    40 ImplementationGroupProxy(TInt& aTableCount)
       
    41     {
       
    42     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
    43     
       
    44     return ImplementationTable;
       
    45     }
       
    46 
       
    47 // ============================ MEMBER FUNCTIONS ==============================
       
    48 // ----------------------------------------------------------------------------
       
    49 // CUpnpAccess::ConstructL
       
    50 // Symbian 2nd phase constructor can leave.
       
    51 // ----------------------------------------------------------------------------
       
    52 //
       
    53 void CUpnpAccess::ConstructL()
       
    54     {
       
    55     }
       
    56 
       
    57 // ----------------------------------------------------------------------------
       
    58 // CUpnpAccess::NewL
       
    59 // Two-phased constructor.
       
    60 // ----------------------------------------------------------------------------
       
    61 //
       
    62 CUpnpAccess* CUpnpAccess::NewL()
       
    63     {
       
    64     CUpnpAccess* self = new (ELeave) CUpnpAccess;
       
    65     DEBUGSTRING(("in NewL 0x%x", self));
       
    66     CleanupStack::PushL(self);
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop(self);
       
    69     return self;
       
    70     }
       
    71 
       
    72 // Destructor
       
    73 CUpnpAccess::~CUpnpAccess()
       
    74     {
       
    75     DEBUGSTRING(("in destructor 0x%x", this));
       
    76     delete iUUID;
       
    77     iAVCPEngineClient.Close();
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // CUpnpAccess::SetupL
       
    82 // ----------------------------------------------------------------------------
       
    83 //
       
    84     void CUpnpAccess::SetupL(MRsfwRemoteAccessObserver*)
       
    85     {    
       
    86     DEBUGSTRING(("in SetupL"));
       
    87     }
       
    88 
       
    89 // ----------------------------------------------------------------------------
       
    90 // CUpnpAccess::OpenL
       
    91 // ----------------------------------------------------------------------------
       
    92 //
       
    93 TUint CUpnpAccess::OpenL(const TUriC& aUri,
       
    94 	                    const TDesC& /* aFriendlyName */,
       
    95 						const TDesC& /* aUserName */,
       
    96                         const TDesC& /* aPassword */,                     
       
    97                         const TDesC& /* aAuxData */,
       
    98                         MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
    99     {
       
   100    
       
   101     TPtrC host(aUri.Extract(EUriHost));
       
   102     DEBUGSTRING16(("open plugin for '%S'", &host));
       
   103         
       
   104     iUUID = HBufC8::NewL(host.Length());
       
   105     iUUID->Des().Copy(host);
       
   106     
       
   107     User::LeaveIfError(iAVCPEngineClient.Connect());
       
   108     
       
   109     aResponseHandler->HandleRemoteAccessResponse(0, KErrNone);
       
   110     return 0;
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CUpnpAccess::GetDirectoryL
       
   115 // ----------------------------------------------------------------------------
       
   116 //
       
   117 TUint CUpnpAccess::GetDirectoryL(const TDesC& aPathName,
       
   118                                 RPointerArray<CRsfwDirEnt>& aDirEnts,
       
   119                                 MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   120     {
       
   121     DEBUGSTRING16(("get directory '%S'", &aPathName));
       
   122 
       
   123     TInt err = iAVCPEngineClient.GetDirectoryL(*iUUID, aPathName, aDirEnts);
       
   124     
       
   125     aResponseHandler->HandleRemoteAccessResponse(0, err);
       
   126     return 0;
       
   127     
       
   128     }
       
   129 
       
   130 // ----------------------------------------------------------------------------
       
   131 // CUpnpAccess::GetDirectoryAttributesL
       
   132 // ----------------------------------------------------------------------------
       
   133 //
       
   134 TUint CUpnpAccess::GetDirectoryAttributesL(const TDesC& aPathName,
       
   135                                           CRsfwDirEntAttr*& aAttr,
       
   136                                           MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   137     {
       
   138     // This function reads attributes of a directory
       
   139     // (not attributes of the files in the directory)
       
   140     DEBUGSTRING16(("Get directory attributes of '%S'", &aPathName));
       
   141     
       
   142     TInt err = iAVCPEngineClient.GetDirectoryAttributeL(*iUUID, aPathName, aAttr);
       
   143 
       
   144     aResponseHandler->HandleRemoteAccessResponse(0, err);
       
   145     return 0;
       
   146     
       
   147     }
       
   148 
       
   149 // ----------------------------------------------------------------------------
       
   150 // CUpnpAccess::GetFileAttributesL
       
   151 // ----------------------------------------------------------------------------
       
   152 //
       
   153 TUint CUpnpAccess::GetFileAttributesL(const TDesC& aPathName,
       
   154                                CRsfwDirEntAttr*& aAttr,
       
   155                                MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   156     {
       
   157     DEBUGSTRING16(("Get file attributes of '%S'", &aPathName));
       
   158     
       
   159     TInt err = iAVCPEngineClient.GetFileAttributeL(*iUUID, aPathName, aAttr);
       
   160         
       
   161     aResponseHandler->HandleRemoteAccessResponse(0, err);
       
   162     return 0;  
       
   163     }
       
   164 
       
   165 // ----------------------------------------------------------------------------
       
   166 // CUpnpAccess::SetAttributesL
       
   167 // ----------------------------------------------------------------------------
       
   168 //
       
   169 TUint CUpnpAccess::SetAttributesL(const TDesC& aPathName,
       
   170                            CRsfwDirEntAttr& /*aAttr*/,
       
   171                            MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   172     {
       
   173     DEBUGSTRING16(("Set attributes of '%S'",
       
   174                   &aPathName));
       
   175 
       
   176     aResponseHandler->HandleRemoteAccessResponse(0, KErrNotSupported);
       
   177     return 0;  
       
   178     }
       
   179 
       
   180 // ----------------------------------------------------------------------------
       
   181 // CUpnpAccess::GetFileL
       
   182 // ----------------------------------------------------------------------------
       
   183 //
       
   184 TUint CUpnpAccess::GetFileL(const TDesC& aRemotePathName,
       
   185                            	const TDesC& aLocalPathName,
       
   186                            	TInt aOffset,
       
   187                            	TInt* aLength,
       
   188                    			TUint aFlags,                           
       
   189                            	MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   190     {
       
   191        
       
   192     DEBUGSTRING16(("get file '%S'", &aRemotePathName));
       
   193     DEBUGSTRING16(("     into file '%S'", &aLocalPathName));
       
   194     
       
   195     TInt length = 0;
       
   196     if (aLength) 
       
   197     {
       
   198         length = *aLength;
       
   199     }
       
   200     DEBUGSTRING(("offset=%d, length=%d", aOffset, length));        
       
   201     	
       
   202     TInt read;
       
   203     TInt err = iAVCPEngineClient.GetFileL(*iUUID, 
       
   204     		aRemotePathName, aLocalPathName, aOffset, length, aFlags, read);
       
   205     		
       
   206     if (aLength) {
       
   207     	*aLength = read;    	
       
   208     }
       
   209              
       
   210     aResponseHandler->HandleRemoteAccessResponse(0, err);
       
   211     return 0; 
       
   212 
       
   213     }
       
   214 
       
   215 // ----------------------------------------------------------------------------
       
   216 // CUpnpAccess::MakeDirectoryL
       
   217 // ----------------------------------------------------------------------------
       
   218 //
       
   219 TUint CUpnpAccess::MakeDirectoryL(const TDesC& aPathName,
       
   220                            MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   221     {
       
   222     DEBUGSTRING16(("Make directory '%S'", &aPathName));
       
   223     
       
   224     TInt err = iAVCPEngineClient.MakeDirectoryL(*iUUID, aPathName);    
       
   225 
       
   226     aResponseHandler->HandleRemoteAccessResponse(0, err);
       
   227     return 0;  
       
   228     }
       
   229 
       
   230 // ----------------------------------------------------------------------------
       
   231 // CUpnpAccess::CreateFileL
       
   232 // ----------------------------------------------------------------------------
       
   233 //
       
   234 TUint CUpnpAccess::CreateFileL(const TDesC& aPathName, TBool aOverWriting,
       
   235                               MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   236     {
       
   237     DEBUGSTRING16(("Create file '%S'", &aPathName));
       
   238     
       
   239     TInt err(0);
       
   240     if (aOverWriting) 
       
   241     	{
       
   242     	DEBUGSTRING16(("delete file '%S'", &aPathName));    
       
   243     	err = iAVCPEngineClient.DeleteFileL(*iUUID, aPathName);       	
       
   244     	}
       
   245     
       
   246     if (err == KErrNone) 
       
   247     	err = iAVCPEngineClient.CreateFileL(*iUUID, aPathName);    
       
   248 
       
   249     aResponseHandler->HandleRemoteAccessResponse(0, err);
       
   250     return 0;  
       
   251     }
       
   252 
       
   253 // ----------------------------------------------------------------------------
       
   254 // CUpnpAccess::PutFileL
       
   255 // ----------------------------------------------------------------------------
       
   256 //
       
   257 TUint CUpnpAccess::PutFileL(const TDesC& aLocalPathName,
       
   258                         	const TDesC& aRemotePathName,
       
   259                    			const TDesC8& /*aMimeType*/,                             
       
   260                            	MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   261     {
       
   262     DEBUGSTRING16(("put file '%S'", &aLocalPathName));
       
   263     DEBUGSTRING16(("     to remote file '%S'", &aRemotePathName));
       
   264         
       
   265     TInt err = iAVCPEngineClient.PutFileL(*iUUID, aLocalPathName, aRemotePathName);    
       
   266 
       
   267     aResponseHandler->HandleRemoteAccessResponse(0, err);
       
   268     return 0;   
       
   269     }
       
   270 
       
   271 // ----------------------------------------------------------------------------
       
   272 // CUpnpAccess::PutFileL
       
   273 // ----------------------------------------------------------------------------
       
   274 //
       
   275 TUint CUpnpAccess::PutFileL(const TDesC& aLocalPathName,
       
   276                            	const TDesC& aRemotePathName,
       
   277 							const TDesC8& /*aMimeType*/,                                                        	
       
   278                            	TInt /* aOffset */,
       
   279                            	TInt /* aLength */,
       
   280                            	TInt /* aTotalLength */,                   			
       
   281                            	MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   282     {
       
   283     DEBUGSTRING16(("put file '%S'", &aLocalPathName));
       
   284     DEBUGSTRING16(("     to remote file '%S'", &aRemotePathName));
       
   285 
       
   286     aResponseHandler->HandleRemoteAccessResponse(0, KErrNotSupported);
       
   287     return 0; 
       
   288     }
       
   289 
       
   290 // ----------------------------------------------------------------------------
       
   291 // CUpnpAccess::DeleteDirectoryL
       
   292 // ----------------------------------------------------------------------------
       
   293 //
       
   294 TUint CUpnpAccess::DeleteDirectoryL(const TDesC& aPathName,
       
   295                              MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   296     {
       
   297     DEBUGSTRING16(("delete directory '%S'", &aPathName));
       
   298     
       
   299     TInt err = iAVCPEngineClient.DeleteDirectoryL(*iUUID, aPathName);    
       
   300 
       
   301     aResponseHandler->HandleRemoteAccessResponse(0, err);
       
   302     return 0;  
       
   303     }
       
   304 
       
   305 // ----------------------------------------------------------------------------
       
   306 // CUpnpAccess::DeleteFileL
       
   307 // ----------------------------------------------------------------------------
       
   308 //
       
   309 TUint CUpnpAccess::DeleteFileL(const TDesC& aPathName,
       
   310                               MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   311     {
       
   312     DEBUGSTRING16(("delete file '%S'", &aPathName));
       
   313     
       
   314     TInt err = iAVCPEngineClient.DeleteFileL(*iUUID, aPathName);    
       
   315 
       
   316     aResponseHandler->HandleRemoteAccessResponse(0, err);
       
   317     return 0;     
       
   318     }
       
   319 
       
   320 // ----------------------------------------------------------------------------
       
   321 // CUpnpAccess::RenameL
       
   322 // ----------------------------------------------------------------------------
       
   323 //
       
   324 TUint CUpnpAccess::RenameL(const TDesC& aSrcPathName,
       
   325                           const TDesC& aDstPathName,
       
   326                           TBool /*aOverwrite*/,
       
   327                           MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   328     {
       
   329     
       
   330     DEBUGSTRING16(("Rename '%S' to '%S'", &aSrcPathName, &aDstPathName));
       
   331     aResponseHandler->HandleRemoteAccessResponse(0, KErrNotSupported);
       
   332     return 0;
       
   333     }
       
   334 
       
   335 // ----------------------------------------------------------------------------
       
   336 // CUpnpAccess::ObtainLockL
       
   337 // ----------------------------------------------------------------------------
       
   338 //
       
   339 
       
   340 TUint CUpnpAccess::ObtainLockL(const TDesC&  aPathName ,
       
   341                         TUint /* aLockFlags */,
       
   342                         TUint& /*aTimeOut*/,
       
   343                         TDesC8*& /* aLockToken */,
       
   344                         MRsfwRemoteAccessResponseHandler*  aResponseHandler )
       
   345     {
       
   346     DEBUGSTRING16(("obtain lock '%S'", &aPathName));    
       
   347 
       
   348     aResponseHandler->HandleRemoteAccessResponse(0, KErrNotSupported);    
       
   349     return 0;
       
   350     }
       
   351 
       
   352 // ----------------------------------------------------------------------------
       
   353 // CUpnpAccess::ReleaseLockL
       
   354 // ----------------------------------------------------------------------------
       
   355 //
       
   356 TUint CUpnpAccess::ReleaseLockL(const TDesC&  aPathName,
       
   357                          MRsfwRemoteAccessResponseHandler*  aResponseHandler)
       
   358     {
       
   359     DEBUGSTRING16(("release lock '%S'", &aPathName));
       
   360 
       
   361     aResponseHandler->HandleRemoteAccessResponse(0, KErrNotSupported);
       
   362     return 0;
       
   363     }
       
   364 
       
   365 // ----------------------------------------------------------------------------
       
   366 // CUpnpAccess::RefreshLockL
       
   367 // ----------------------------------------------------------------------------
       
   368 //
       
   369 TUint CUpnpAccess::RefreshLockL(const TDesC&  aPathName, TUint& /*aTimeOut*/,
       
   370                          MRsfwRemoteAccessResponseHandler* aResponseHandler)
       
   371     {
       
   372     DEBUGSTRING16(("refresh lock '%S'", &aPathName));
       
   373     
       
   374     aResponseHandler->HandleRemoteAccessResponse(0, KErrNotSupported);    
       
   375     return 0;
       
   376     }
       
   377     
       
   378 // ----------------------------------------------------------------------------
       
   379 // CUpnpAccess::SetLockToken
       
   380 // ----------------------------------------------------------------------------
       
   381 //
       
   382 TInt CUpnpAccess::SetLockToken(const TDesC& /* aPathName */,
       
   383                               const TDesC8& /* aLockToken */)
       
   384     {
       
   385     return KErrNotSupported;
       
   386     }
       
   387     
       
   388 // ----------------------------------------------------------------------------
       
   389 // CUpnpAccess::CancelL
       
   390 // ----------------------------------------------------------------------------
       
   391 //
       
   392 void CUpnpAccess::Cancel(TDesC& /* aTargetPath */)
       
   393     {
       
   394     // Nothing to cancel
       
   395     }
       
   396 // ----------------------------------------------------------------------------
       
   397 // CUpnpAccess::CancelL
       
   398 // ----------------------------------------------------------------------------
       
   399 //
       
   400 void CUpnpAccess::Cancel(TUint /* aId */)
       
   401     {
       
   402     // Nothing to cancel
       
   403     }
       
   404 
       
   405 
       
   406 //  End of File