- Changed the GetDefaultWallet() function to address all scenarios.
This commit is contained in:
parent
c7cb705272
commit
9c4ea3868b
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 7 23:02:38 IST 2006 - lsreevatsa@novell.com
|
||||
|
||||
- Changed the GetDefaultWallet() function to address all scenarios.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 7 19:20:50 IST 2006 - smanojna@novell.com
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <dcopclient.h>
|
||||
#include<iostream.h>
|
||||
|
||||
#define MAX_LENGTH 256
|
||||
|
||||
using namespace KWallet;
|
||||
using namespace std;
|
||||
|
||||
@ -253,55 +255,45 @@ extern "C"
|
||||
|
||||
}
|
||||
|
||||
void GetDefaultWallet(char dwallet[100])
|
||||
char * GetDefaultWallet()
|
||||
{
|
||||
char *ptr = NULL;
|
||||
char homedir[100];
|
||||
char defaultwallet[100];
|
||||
strcpy(homedir, getenv("HOME"));
|
||||
char *homedir = getenv("HOME");;
|
||||
char *defaultwallet = NULL;
|
||||
defaultwallet = (char *)malloc(MAX_LENGTH);
|
||||
FILE *fs;
|
||||
char str[100];
|
||||
int i;
|
||||
char str[MAX_LENGTH];
|
||||
char *str1 = "Default Wallet=";
|
||||
int i,j,k;
|
||||
//cout<<"kwallets_rw.cpp : Home Directory =" << homedir;
|
||||
strcat(homedir, "/.kde/share/config/kwalletrc");
|
||||
//cout << "\nkwallets_rw.cpp : Home directory full path = " << homedir;
|
||||
fs = fopen(homedir,"r");
|
||||
//fs = fopen("/root/.kde/share/config/kwalletrc","r");
|
||||
if(!fs)
|
||||
{
|
||||
strcpy(dwallet, "kdewallet");
|
||||
return;
|
||||
return "kdewallet";
|
||||
}
|
||||
|
||||
while(!feof(fs))
|
||||
{
|
||||
fgets(str,80,fs);
|
||||
//cout<<str;
|
||||
ptr = strstr(str,"Default Wallet");
|
||||
//cout<<"got it";
|
||||
|
||||
if(ptr == NULL)
|
||||
continue;
|
||||
else
|
||||
fgets(str,MAX_LENGTH,fs);
|
||||
for(i=0;str[i]&&str1[i];i++)
|
||||
{
|
||||
ptr = strchr(str,'=');
|
||||
ptr++;
|
||||
i=0;
|
||||
while(*ptr != '\n')
|
||||
{
|
||||
//printf("%c",*ptr);
|
||||
defaultwallet[i] = *ptr;
|
||||
ptr++;
|
||||
i++;
|
||||
}
|
||||
defaultwallet[i] = '\0';
|
||||
break;
|
||||
if(str[i] == str1[i])
|
||||
continue;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
//return NULL;
|
||||
//cout<<"Default Wallet : " << defaultwallet;
|
||||
strcpy(dwallet,defaultwallet);
|
||||
//return defaultwallet;
|
||||
}
|
||||
if(i==strlen(str1))
|
||||
{
|
||||
for(j=i,k=0;j<strlen(str);j++,k++)
|
||||
defaultwallet[k] = str[j];
|
||||
defaultwallet[k-1] = '\0';
|
||||
return defaultwallet;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
return "kdewallet";
|
||||
}
|
||||
|
||||
int RemoveEntry(char *name, char *foldername, char *keyname)
|
||||
{
|
||||
@ -310,16 +302,18 @@ void GetDefaultWallet(char dwallet[100])
|
||||
}
|
||||
int SetEntry(char *name, char *foldername, int entryType, char *keyname, char *value, int valueLen )
|
||||
{
|
||||
char dwallet[100];
|
||||
GetDefaultWallet(dwallet); //function called here
|
||||
char *dwallet = NULL;
|
||||
dwallet = (char *)malloc(MAX_LENGTH);
|
||||
dwallet = GetDefaultWallet(); //function called here
|
||||
DCOPDemoWidget kw;
|
||||
//printf("kwallet : In Set Entry\n");
|
||||
return(kw.SetEntry(dwallet,foldername,entryType,keyname,value,valueLen));
|
||||
}
|
||||
int SetMapEntry(char *name, char *foldername, char *keyname, char **value, int eleCount )
|
||||
{
|
||||
char dwallet[100];
|
||||
GetDefaultWallet(dwallet);//function called here
|
||||
char *dwallet = NULL;
|
||||
dwallet = (char *)malloc(MAX_LENGTH);
|
||||
dwallet = GetDefaultWallet(); //function called here
|
||||
DCOPDemoWidget kw;
|
||||
//printf("kwallet: SetMapEntry\n");
|
||||
return(kw.SetMap(dwallet,foldername,keyname,value,eleCount));
|
||||
|
Loading…
Reference in New Issue
Block a user