ofdbus/dbus/dbus/dbus-sysdeps-unix-helper.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 11 Jun 2010 15:26:22 +0300
changeset 34 5fae379060a7
parent 0 e4d67989cc36
permissions -rw-r--r--
Revision: 201023 Kit: 2010123

/*
* 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: 
*
*/

 

 #include <f32file.h>
 #include <e32des16.h>
 #include "dbus-sysdeps-unix-helper.h"
 #include "dbus-list.h"
 #include "dbus-string.h"
 

#define DBUS_STANDARD_SESSION_SERVICEDIR "\\dbus1\\services"
#define DBUS_DATADIR_HARWARE ":\\data\\dbus"


 int AppendDir(DBusList **dirs)
 { 
         // Show the Input List
 RFs fs;
 User::LeaveIfError(fs.Connect());
 TFindFile findFile(fs);
 CDir *aDir = NULL;
 char *cpath = NULL;
  
 // char *cpath;
  //char *driveletter = (char *)malloc(2*sizeof(char));
  
  

 if (findFile.FindWildByDir(_L("*.service"),_L("\\data\\dbus\\dbus1\\services\\"),aDir) == KErrNone   )
{

  /*         if (!_dbus_string_append (&servicedir_path,DBUS_DATADIR))
        goto oom;
  
   if (!_dbus_string_append (&servicedir_path,DBUS_UNIX_STANDARD_SESSION_SERVICEDIR))
        goto oom;
  
    if (!_dbus_string_copy_data(&servicedir_path, &cpath))
        {
          goto oom;
        }*/
//TInt count = aDir->Count();
char *driveletter = new char[2];
//TEntry entry;
do
{

	TBuf16<256> buf16(findFile.File());
	DBusString servicedir_path;
  if (!_dbus_string_init (&servicedir_path))
    return 0;

		 cpath = (char *)(buf16.PtrZ());
		driveletter[0] =	cpath[0];
		cpath = NULL;
//	driveletter[0] = AppendDir(dirs);
        driveletter[1] = '\0';
        if (!_dbus_string_append (&servicedir_path,driveletter))
         return 0;
        
        if (!_dbus_string_append (&servicedir_path,DBUS_DATADIR_HARWARE))
         return 0;
  
   if (!_dbus_string_append (&servicedir_path,DBUS_STANDARD_SESSION_SERVICEDIR))
         return 0;
  
    if (!_dbus_string_copy_data(&servicedir_path, &cpath))
        {
          return 0;;
        }

      if (!_dbus_list_append (dirs, cpath))
        {
                     
          dbus_free (cpath);
           return 0;
        }

_dbus_string_free (&servicedir_path);
        
}while(findFile.FindWild(aDir)!= KErrNotFound);
}
    return 1;
}



char getDaemonDriveLetter()
{
	 RFs fs;
 User::LeaveIfError(fs.Connect());
 TFindFile findFile(fs);
 
 char *cpath = NULL;
  char *driveletter = new char[2];
  

 if (findFile.FindByDir(_L("dbusdaemon.exe"),_L("\\sys\\bin\\")) == KErrNone   )
{





	TBuf16<256> buf16(findFile.File());


		 cpath = (char *)(buf16.PtrZ());
		driveletter[0] =	cpath[0];
		cpath = NULL;

        driveletter[1] = '\0';
	
}
delete cpath;
return driveletter[0];
}