major source structure and module name changes

This commit is contained in:
soochoi
2006-06-07 16:34:19 +00:00
parent 5c75241b4b
commit 1fa6f07e83
651 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("Novell.CASA.DataEngines.KWallet.dll")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Novell, Inc")]
[assembly: AssemblyProduct("CASA")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.6.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

View File

@@ -0,0 +1,45 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
using System;
using System.Text;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
namespace Novell.CASA.DataEngines.KWallet
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class EnumSecretList
{
public IntPtr walletName;
public IntPtr folderName;
public int entryType;
public IntPtr secretVal;
public IntPtr next;
};
}

View File

@@ -0,0 +1,193 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
using System;
using System.Text;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
namespace Novell.CASA.DataEngines.KWallet
{
public class kwallet
{
//private static int MAX_NAME_LENGTH = 512;
private const string CPP_LIB = "casakwallet";
/*
[DllImport(CPP_LIB)]
public static extern void MyTest(
EnumSecretList enumSecretList
);
*/
[DllImport(CPP_LIB)]
public static extern void Aggregate(
EnumSecretList enumSecretList
);
[DllImport(CPP_LIB)]
public static extern void FreeList();
[DllImport(CPP_LIB)]
public static extern int SetEntry(string walletName, string folderName, int entryType, string keyName, string value, int valueLen);
[DllImport(CPP_LIB)]
public static extern int SetMapEntry(string walletName, string folderName, string keyName, String[,] value, int eleCount);
[DllImport(CPP_LIB)]
public static extern int RemoveEntry(string walletName, string folderName, string keyName);
/*
public static int Try(EnumSecretList enumSecretList)
{
MyTest(enumSecretList);
return 0;
}
*/
public static int AggregateKW(EnumSecretList enumSecretList)
{
Aggregate(enumSecretList);
return 0;
}
public static int FreeResources()
{
FreeList();
return 0;
}
public static int SetSecret(string walletName, string folderName, int entryType, string keyName, string value, int valueLen )
{
return(SetEntry(walletName, folderName, entryType, keyName, value, valueLen ));
}
public static int SetSecret(string walletName, string folderName, string keyName, NameValueCollection nvc)
{
String[,] mapele = new String[nvc.Count,2 ];
for (int i=0; i< nvc.Count; i++)
{
mapele[i,0] = nvc.GetKey(i);
mapele[i,1] = nvc.Get(nvc.GetKey(i));
}
return(SetMapEntry(walletName, folderName, keyName, mapele, nvc.Count));
}
public static int DeleteSecret(string walletName, string folderName, string keyName)
{
return(RemoveEntry(walletName, folderName, keyName));
}
//TBD: All this for future.
/*
[DllImport(CPP_LIB)]
public static extern int ReadSecret
(
[MarshalAs(UnmanagedType.LPStr)]
String walletName,
[MarshalAs(UnmanagedType.LPStr)]
String folderName,
[MarshalAs(UnmanagedType.LPStr)]
String key,
[MarshalAs(UnmanagedType.LPStr)]
Byte[] secretVal
);
[DllImport(CPP_LIB)]
public static extern int WriteSecret
(
[MarshalAs(UnmanagedType.LPStr)]
String walletName,
[MarshalAs(UnmanagedType.LPStr)]
String folderName,
int entryType,
[MarshalAs(UnmanagedType.LPStr)]
String key,
[MarshalAs(UnmanagedType.LPStr)]
Byte[] secret
);
[DllImport(CPP_LIB)]
public static extern void CloseAllWallets();
public static int ReadWallet(String walletName, String folderName, String key, Byte[] secretVal)
{
// Read a secret from wallet
return (ReadSecret(walletName, folderName, key, secretVal));
}
public static int WriteWallet(String walletName, String folderName,int entryType, String key, Byte[] secretVal)
{
// Write secret to wallet
return (WriteSecret( walletName, folderName, entryType, key, secretVal));
}
public static void DisconnectApplication()
{
CloseAllWallets();
}
*/
}
}

107
adlib/ad_kw/Makefile.am Normal file
View File

@@ -0,0 +1,107 @@
#######################################################################
#
# Copyright (C) 2006 Novell, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#######################################################################
if DEBUG
TARGET_CFG = Debug
CFLAGS += -v -w
CS_EXTRA_FLAGS = $(CSCFLAGS_DEBUG)
else
TARGET_CFG = Release
endif
#SUBDIRS = native
#DIST_SUBDIRS = native
EXTRA_DIST = $(CSFILES)
CASAROOT = ../..
CASALIBDIR = $(CASAROOT)/$(LIB)
# handle Mono secondary dependencies
export MONO_PATH := $(MONO_PATH)
PLATFORMINDEPENDENTSOURCEDIR =
PLATFORMDEPENDENTSOURCEDIR = .
MODULE_NAME =Novell.CASA.DataEngines.KWallet
MODULE_EXT =dll
CSFILES = $(srcdir)/AssemblyInfo.cs \
$(srcdir)/KWalletEnum.cs \
$(srcdir)/KWalletNative.cs
CSFILES_CSC := $(subst /,$(SEP),$(CSFILES))
CS_FLAGS = $(CSC_LIBFLAG)
CS_RESOURCES =
CS_LIBS =
CS_LIBPATH =
OBJDIR = ./$(TARGET_CFG)/$(LIB)
#OBJS = $(addprefix $(OBJDIR)/, $(CSFILES:%.dll=%.cs))
CUR_DIR := $(shell pwd)
all: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
#
# Pattern based rules.
#
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
vpath %.cs $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(CSFILES)
$(CSC) $(CS_FLAGS) $(CS_EXTRA_FLAGS) -out:$@ $(CSFILES_CSC)
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
#$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(OBJS)
# @echo [======== Linking $@ ========]
# $(LINK) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
# cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
$(OBJDIR):
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
[ -d $(CASALIBDIR) ] || mkdir -p $(CASALIBDIR)
[ -d $(CASALIBDIR)/$(TARGET_CFG) ] || mkdir -p $(CASALIBDIR)/$(TARGET_CFG)
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
$(mkinstalldirs) $(DESTDIR)$(libdir)
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
uninstall-local:
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
rmdir $(DESTDIR)$(libdir)
#installcheck-local: install
# $(mkinstalldirs) $(DESTDIR)$(libdir)
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
# cd $(DESTDIR)$(libdir); $(MONO)
clean-local:
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
distclean-local:
maintainer-clean-local:
rm -f Makefile.in

View File

@@ -0,0 +1,125 @@
#######################################################################
#
# Copyright (C) 2006 Novell, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#######################################################################
if DEBUG
TARGET_CFG = Debug
CFLAGS += -v -w
else
TARGET_CFG = Release
endif
SUBDIRS =
DIST_SUBDIRS =
EXTRA_DIST = $(CXXFILES) $(CXX_MOC_FILES) *.h
CASAROOT = ../../..
CASALIBDIR = $(CASAROOT)/$(LIB)
BUILD_VER = 1.1.1
# handle Mono secondary dependencies
export MONO_PATH := $(MONO_PATH)
PLATFORMINDEPENDENTSOURCEDIR =
PLATFORMDEPENDENTSOURCEDIR = .
####this needs to be defined in configure.in
MOC = /usr/lib/qt3/bin/moc
CXX = g++
MODULE_NAME =libkwallets_rw
MODULE_EXT =so
CXXFILES = $(srcdir)/kwallets_rw.cpp
CXX_MOC_FILES = kwallets_rw.moc
CXXFILES_CXX :=
INCLUDES = -I. -I.. -I$(CASAROOT)/include \
-I/opt/kde3/include -I/usr/lib/qt3/include -I/usr/X11R6/include -I/opt/gnome/include/gnome-keyring-1/
CXXFLAGS = $(CPP_LIBFLAG) $(INCLUDES)
EXTRA_CXXFLAGS = -fPIC -DPIC -DSSCS_LINUX_PLAT_F -DQT_THREAD_SUPPORT -DQT_CLEAN_NANESPACE \
-DQT_NO_ASCII_CAS -O2 -fmessage-length=0 -Wall -g -D_REENTRANT \
-DALIGNMENT -DN_PLAT_UNIX -DUNIX -DLINUX -DIAPX386
CXX_RESOURCES =
LIBS = -lpthread -ldl
LDFLAGS = -fno-exception -fno-check-new -Wl,-Bsymbolic -shared -pthread -O2 \
-Wl,-soname -Wl,libkwallets_rw.so.1
EXTRA_LDFLAGS = -L/opt/kde3/$(LIB) -lkwalletclient \
-lqt-mt -L/usr/X11R6/$(LIB) -L/usr/lib/qt3/$(LIB) -lqt-mt
OBJDIR = ./$(TARGET_CFG)/$(LIB)
OBJS = $(addprefix $(OBJDIR)/, $(CXXFILES:%.cpp=%.o))
CUR_DIR := $(shell pwd)
all: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER)
#
# Pattern based rules.
#
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
vpath %.cs $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
$(CXX_MOC_FILES): kwallets_rw.h
$(MOC) $^ -o $@
$(OBJDIR)/%.o: %.cpp
# $(CXX) -c $(CXXFLAGS) $(EXTRA_CXXFLAGS) -o $@ $<
c++ -c -g $(CXXFLAGS) $(EXTRA_CXXFLAGS) -o $@ $<
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER):$(CXX_MOC_FILES) $(OBJDIR) $(OBJS)
@echo [======== Linking $@ ========]
c++ -o $@ $(LDFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(LIBS)
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER)
ln -sf $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).1
$(OBJDIR):
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
[ -d $(CASALIBDIR) ] || mkdir -p $(CASALIBDIR)
[ -d $(CASALIBDIR)/$(TARGET_CFG) ] || mkdir -p $(CASALIBDIR)/$(TARGET_CFG)
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
$(mkinstalldirs) $(DESTDIR)$(libdir)
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
uninstall-local:
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
rmdir $(DESTDIR)$(libdir)
#installcheck-local: install
# $(mkinstalldirs) $(DESTDIR)$(libdir)
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
# cd $(DESTDIR)$(libdir); $(MONO)
clean-local:
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
if [ -f $(CXX_MOC_FILES) ]; then rm -f $(CXX_MOC_FILES); fi
distclean-local:
maintainer-clean-local:
rm -f Makefile.in

View File

@@ -0,0 +1,71 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
// -*- c++ -*-
#ifndef DCOPIFACEDEMO_H
#define DCOPIFACEDEMO_H
#include <qvbox.h>
/**
* Adding DCOP interface to the Console.
*
*/
struct EnumSecretList
{
// struct SecretInfo *sInfo;
char *walletName;
char *folderName;
int entryType;
char *secretVal;
struct EnumSecretList *next;
};
class DCOPDemoWidget : public QObject
{
Q_OBJECT
public:
DCOPDemoWidget();
~DCOPDemoWidget();
public slots:
int ReadAllWalletSecrets(struct EnumSecretList **);
private:
int ReadKey(Wallet *, QString, QByteArray*);
};
#endif

View File

@@ -0,0 +1,656 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
#include<stdio.h>
#include <kapp.h>
#include <kcmdlineargs.h>
#include<kwallet.h>
#include <dcopclient.h>
#include<iostream.h>
#define MAX_LENGTH 256
using namespace KWallet;
using namespace std;
#include "kwallets_rw.h"
#include "kwallets_rw.moc"
//#include "mytest.h"
// char *applName="dcopifacedemo";
char *applName="casaconsole";
QStringList walletList;
DCOPDemoWidget *win = new DCOPDemoWidget();
DCOPDemoWidget::DCOPDemoWidget()
{
int ret = 0;
kapp->dcopClient()->isRegistered() ;
if (!ret)
{
if(kapp->dcopClient()->registerAs( "casaconsole" ).isEmpty())
{
kapp->startKdeinit();
kapp->dcopClient()->isRegistered() ;
if (!ret)
{
if (kapp->dcopClient()->registerAs( "casaconsole" ).isEmpty())
{
printf("Cannot setup DCOP communication. Start kdeinit manually\n");
return;
}
}
}
}
/* if ( !kapp->dcopClient()->isRegistered() ) {
kapp->dcopClient()->registerAs( "casaconsole" );
}
*/
}
DCOPDemoWidget::~DCOPDemoWidget()
{
for ( QStringList::Iterator walletIter = walletList.begin(); walletIter != walletList.end(); ++walletIter )
{
QString walletName = (*walletIter);
Wallet::disconnectApplication(walletName,applName);
}
}
int DCOPDemoWidget::ReadKey(Wallet *wallet,QString key, QByteArray *secretVal)
{
// Read the secret from the entry
QByteArray value;
//printf("kwallet: Read Key entered\n");
if (wallet->readEntry(key, value)==0)
{
if (value)
{
*secretVal = value;
QDataStream convert(*secretVal, IO_ReadOnly);
if (wallet->entryType(key) == 1 )
{
//Commented by Austin
/* // Convert the ByteArray to QString
QString passwd;
printf("In read Entry Convert Final before success\n");
convert >> passwd;
printf("In read Entry Convert Final success\n");
*/
} else if (wallet->entryType(key) == 3)
{
// If the entry is of type "map"
// Convert the ByteArray to QMap
QMap<QString,QString> mapSecret;
convert >> mapSecret;
// Iterate through each map entry.
QMap<QString,QString>::Iterator mapIter;
QString tempSecret = QString::fromLatin1("");
for ( mapIter = mapSecret.begin(); mapIter != mapSecret.end(); ++mapIter )
{
// This logic has to be improved
tempSecret.append(mapIter.key().latin1());
tempSecret.append(":");
tempSecret.append(mapIter.data().latin1());
if ((++mapIter) != mapSecret.end())
tempSecret.append(";");
--mapIter;
}
// Convert the QString to QByteArray
QDataStream stream(*secretVal, IO_WriteOnly);
stream << tempSecret ;
}
} else
{
//printf("Could not read the entry..inner IF\n");
return -1;
}
} else
{
//printf("Could not read the entry Inside wallet->readkey\n");
return -1;
}
return 0;
}
extern "C"
{
static struct EnumSecretList *tempEnumSecrets = NULL;
//void MyTest(struct EnumSecretList *enumWalletSecrets)
void Aggregate(struct EnumSecretList *enumWalletSecrets)
{
//printf("inside natiove agg");
int retVal = 0;
tempEnumSecrets = NULL;
retVal = win->ReadAllWalletSecrets(&tempEnumSecrets);
struct EnumSecretList *iter = tempEnumSecrets;
//struct EnumSecretList *head = tempEnumSecrets;
/*
if (iter == NULL)
{
printf("Native has given NULLLL\n");
enumWalletSecrets = NULL;
return;
}
*/
while (iter != NULL)
{
/*
printf("\n\n**Wallet Name : %s\n",iter->walletName);
printf("\t**Folder Name : %s\n",iter->folderName);
printf("\t\t**Secret Type : %d\n",iter->entryType);
printf("\t\t\t**Secret Value : %s\n",iter->secretVal);
*/
enumWalletSecrets->walletName = iter->walletName;
enumWalletSecrets->folderName = iter->folderName;
enumWalletSecrets->secretVal = iter->secretVal;
enumWalletSecrets->entryType = iter->entryType;
enumWalletSecrets->next = iter->next;
iter = iter->next;
if (iter != NULL)
{
enumWalletSecrets = enumWalletSecrets->next ;
}
else
{
enumWalletSecrets = NULL;
}
}
/*
// Free the list
struct EnumSecretList *temp;
while (head != NULL)
{
free(head->walletName);
free(head->folderName);
free(head->secretVal);
//free(head->entryType);
temp = head->next;
free(head);
head = temp;
}
*/
}
char * GetDefaultWallet()
{
char *homedir = NULL;
char *defaultwallet = NULL;
char *str1 = "Default Wallet=";
char str[MAX_LENGTH];
FILE *fs = NULL;
int i,j,k;
defaultwallet = (char *)malloc(MAX_LENGTH);
homedir = (char *)malloc(MAX_LENGTH);
strcpy(homedir, getenv("HOME"));
strcat(homedir, "/.kde/share/config/kwalletrc");
strcat(homedir,"\0");
fs = fopen(homedir,"r");
if(fs == NULL)
{
free (homedir);
free (defaultwallet);
return "kdewallet";
}
while(!feof(fs))
{
fgets(str,MAX_LENGTH,fs);
for(i=0; str[i] && str1[i]; i++)
{
if(str[i] == str1[i])
continue;
else
break;
}
if(i==strlen(str1))
{
for(j=i,k=0;j<strlen(str);j++,k++)
defaultwallet[k] = str[j];
defaultwallet[k-1] = '\0';
free(homedir);
return defaultwallet;
}
else
continue;
}
free(homedir);
return "kdewallet";
}
int RemoveEntry(char *name, char *foldername, char *keyname)
{
DCOPDemoWidget kw;
return(kw.RemoveEntry(name,foldername,keyname));
}
int SetEntry(char *name, char *foldername, int entryType, char *keyname, char *value, int valueLen )
{
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 = 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));
}
void FreeList()
{
struct EnumSecretList *head = tempEnumSecrets;
// Free the list
struct EnumSecretList *temp;
while (head != NULL)
{
free(head->walletName);
free(head->folderName);
free(head->secretVal);
//free(head->entryType);
temp = head->next;
free(head);
head = temp;
}
tempEnumSecrets = NULL;
}
}
int DCOPDemoWidget::ReadAllWalletSecrets(struct EnumSecretList **enumWalletSecrets)
{
walletList = Wallet::walletList();
for ( QStringList::Iterator walletIter = walletList.begin(); walletIter != walletList.end(); ++walletIter )
{
QString walletName = (*walletIter);
// printf("The wallet name is %s\n",(*walletIter).latin1());
// Open the wallet
Wallet *wallet = NULL;
wallet = Wallet::openWallet(walletName,0,Wallet::Synchronous);
if (wallet == NULL)
{
//printf("Could not open the wallet\n");
return -1;
}
// Get the folder list of the wallet
QStringList folderList = wallet->folderList();
for ( QStringList::Iterator folderIter = folderList.begin(); folderIter != folderList.end(); ++folderIter)
{
// printf("\t%s\n",(*folderIter).latin1());
QString folderName = (*folderIter);
// Set the current folder
if (!(wallet->setFolder(folderName)))
{
//printf("Could not set the folder\n");
return -1;
}
// Get the list of entries in the folder
QStringList entryList = wallet->entryList();
for ( QStringList::Iterator entryIter = entryList.begin(); entryIter != entryList.end(); ++entryIter)
{
//printf("Entry Name : \t\t%s\n",(*entryIter).latin1());
// Read the secret from the entry
QString key = (*entryIter);
QByteArray *secretVal = new QByteArray();
if (ReadKey(wallet,key,secretVal) != 0)
{
//printf("Could not read \"%s\"\n",key.latin1());
break;
//FIXME
}
struct EnumSecretList *tempWalletSecrets = (struct EnumSecretList*)malloc(sizeof(struct EnumSecretList));
if (tempWalletSecrets == NULL) {
//printf("Memory Allocation failure\n");
return -1;
}
tempWalletSecrets->walletName = (char*)malloc(512);
if (tempWalletSecrets->walletName == NULL)
{
//printf("Memory Allocation failure\n");
return -1;
}
//printf("Wallet Name is %s\n",walletName.latin1());
strcpy(tempWalletSecrets->walletName, walletName.latin1());
tempWalletSecrets->folderName = (char*)malloc(512);
if (tempWalletSecrets->folderName == NULL)
{
//printf("Memory Allocation failure\n");
return -1;
}
// printf("Folder Name is %s\n",folderName.latin1());
strcpy(tempWalletSecrets->folderName, folderName.latin1());
tempWalletSecrets->entryType = wallet->entryType(key);
// printf("EntryType is %d\n",wallet->entryType(key));
if (*enumWalletSecrets == NULL)
{
*enumWalletSecrets = tempWalletSecrets;
}
else
{
struct EnumSecretList *iter;
for(iter=*enumWalletSecrets; iter->next!=NULL; iter=iter->next);
iter->next = tempWalletSecrets;
}
tempWalletSecrets->next = NULL;
//Commented by Austin
QDataStream convert(*secretVal, IO_ReadOnly);
QString passwd;
convert >> passwd;
//QString passwd(*secretVal);
//printf("kwallet : ReadAll key %s value %s \n",key.latin1(), passwd.latin1());
tempWalletSecrets->secretVal = (char*)malloc(512);
if (tempWalletSecrets->secretVal == NULL)
{
//printf("Memory Allocation failure\n");
return -1;
}
strcpy(tempWalletSecrets->secretVal,key.latin1());
//printf("After strcpy - 1 - key is %s\n",key.latin1());
strcat(tempWalletSecrets->secretVal,"=");
//printf("After strcat = \n");
if(passwd)
{
//printf("Passwd is %s\n",passwd.latin1());
strcat(tempWalletSecrets->secretVal,passwd.latin1());
}
// Free memory
free(secretVal);
// printf("After free\n");
}
}
// Print all the secrets
/*
struct EnumSecretList *iter = *enumWalletSecrets;
while (iter != NULL)
{
printf("\n\nWallet Name : %s\n",iter->walletName);
printf("\tFolder Name : %s\n",iter->folderName);
printf("\t\tSecret Type : %d\n",iter->entryType);
printf("\t\t\t Secret Value : %s\n",iter->secretVal);
iter = iter->next;
}
*/
}
return(0);
}
int DCOPDemoWidget::SetEntry(char *name, char *foldername, int entryType, char *keyname, char *value, int valueLen )
{
QString qWalletName(name);
QString qKey(keyname);
QString qFolderName(foldername);
QString &refQKey = qKey;
// Open the wallet
Wallet *wallet = NULL;
wallet = Wallet::openWallet(qWalletName,0,Wallet::Synchronous);
if (wallet == NULL)
{
//printf("Could not open the wallet %s \n", qWalletName.latin1());
return KWALLET_RESULT_CANNOT_OPEN_WALLET;
}
if (wallet->setFolder(qFolderName) == false)
{
//printf("Could not open the folder %s \n", qFolderName.latin1());
return KWALLET_RESULT_CANNOT_OPEN_FOLDER;
}
QString unicodeValue = tr(value);
// Read the secret from the entry
//QByteArray secretVal(valueLen *2 );
QByteArray secretVal;
QDataStream ds(secretVal, IO_WriteOnly);
ds << unicodeValue;
/*for(int i=0; i< valueLen; i++)
{
secretVal[i] = 0;
secretVal[i+1] = value[i];
}
*/
//secretVal[valueLen] = '\0';
// secretVal.fill('a');
//secretVal.setRawData(value,valueLen);
QByteArray &refSecretVal = secretVal;
//QDataStream convert( secretVal, IO_WriteOnly );
//convert.readBytes( value, (uint)valueLen);
// Wallet::EntryType MyEntryType = 3;
if (wallet->entryType(qKey) != 3)
{
//printf("kwallet : SetEntry : Before setting Entry key %s value = %s EntryType =%d \n" , qKey.latin1() , value, entryType );
if (wallet->writeEntry(refQKey, refSecretVal , (Wallet::EntryType) entryType ) != 0)
{
return KWALLET_RESULT_CANNOT_WRITE_ENTRY;
}
}
// Free memory
wallet->sync();
return KWALLET_RESULT_OK;
}
int DCOPDemoWidget::SetMap(char *name, char *foldername, char *keyname, char **value, int numOfKeys )
{
QString qWalletName(name);
QString qKey(keyname);
QString qFolderName(foldername);
//printf("kwallet : SetMap : Wallet %s Folder %s Key =%s\n", name, foldername, keyname);
// Open the wallet
Wallet *wallet = NULL;
wallet = Wallet::openWallet(qWalletName,0,Wallet::Synchronous);
if (wallet == NULL)
{
//printf("Could not open the wallet\n");
return KWALLET_RESULT_CANNOT_OPEN_WALLET;
}
if (wallet->hasFolder(qFolderName) == false)
{
if(wallet->createFolder(qFolderName) == false)
{
return KWALLET_RESULT_CANNOT_CREATE_FOLDER;
}
}
if (wallet->setFolder(qFolderName) == false)
{
return KWALLET_RESULT_CANNOT_OPEN_FOLDER;
}
QMap<QString,QString> mapSecret;
for (int i=0; i < numOfKeys * 2; i+=2)
{
QString mapelekey((char *)value[i]);
QString mapelevalue((char *)value[i+1]);
mapSecret.insert(mapelekey,mapelevalue);
}
if (wallet->writeMap(qKey,mapSecret) != 0 )
{
return KWALLET_RESULT_CANNOT_WRITE_ENTRY;
}
wallet->sync();
return KWALLET_RESULT_OK;
}
int DCOPDemoWidget::RemoveEntry(char *name, char *foldername, char *keyname )
{
QString qWalletName(name);
QString qKey(keyname);
QString qFolderName(foldername);
//printf("In DCOPDemoWidget:RemoveEntry\n");
//printf("In DCOPDemoWidget:False %d\n",false);
//printf("In DCOPDemoWidget:False %d\n",FALSE);
// Open the wallet
Wallet *wallet = NULL;
wallet = Wallet::openWallet(qWalletName,0,Wallet::Synchronous);
if (wallet == NULL)
{
//printf("Could not open the wallet %s \n", qWalletName.latin1());
return KWALLET_RESULT_CANNOT_OPEN_WALLET;
}
if (wallet->setFolder(qFolderName) == false)
{
//printf("Could not set the folder %s \n", qFolderName.latin1());
return KWALLET_RESULT_CANNOT_OPEN_FOLDER;
}
if (wallet->removeEntry(qKey) != 0)
{
//printf("Could not remove Entry %s \n", qKey.latin1());
return KWALLET_RESULT_CANNOT_REMOVE_ENTRY;
}
wallet->sync();
//printf("In DCOPDemoWidget:RemoveEntry Exit\n");
return KWALLET_RESULT_OK;
}

View File

@@ -0,0 +1,97 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
// -*- c++ -*-
#ifndef DCOPIFACEDEMO_H
#define DCOPIFACEDEMO_H
#include <qvbox.h>
enum KWalletResult
{ KWALLET_RESULT_OK,
KWALLET_RESULT_CANNOT_OPEN_WALLET,
KWALLET_RESULT_CANNOT_OPEN_FOLDER,
KWALLET_RESULT_CANNOT_WRITE_ENTRY,
KWALLET_RESULT_MALFORMED_XML,
KWALLET_RESULT_CANNOT_CREATE_FOLDER,
KWALLET_RESULT_CANNOT_CREATE_WALLET,
KWALLET_RESULT_CANNOT_REMOVE_ENTRY,
KWALLET_RESULT_UNKNOWN_ERROR
};
/**
* Adding DCOP interface to an app.
*/
struct EnumSecretList
{
char *walletName;
char *folderName;
int entryType;
char *secretVal;
struct EnumSecretList *next;
};
struct TryEnumSecretList
{
char *name;
struct TryEnumSecretList *next;
};
class DCOPDemoWidget : public QObject
{
Q_OBJECT
public:
DCOPDemoWidget();
~DCOPDemoWidget();
public slots:
// void dump();
int ReadAllWalletSecrets(struct EnumSecretList **);
// int ReadWalletSecret(QString, QString, QString, QByteArray*);
// int WriteWalletSecret(QString, QString, QString, QByteArray , int);
int SetEntry(char *, char *, int , char *, char *, int);
int SetMap(char *, char *, char *, char** , int );
int RemoveEntry(char *, char *, char *);
private:
int ReadKey(Wallet*, QString, QByteArray*);
};
#endif

View File

@@ -0,0 +1,14 @@
LINK = $(CPP) \
-Wl,-Bsymbolic \
-shared \
-pthread \
-O2 -fno-exceptions -fno-check-new \
-Wl,-rpath -Wl,/usr/lib$(ARC) \
-L/usr/lib$(ARC) -lpthread -lc -ldl \
-L/opt/kde3/lib$(ARC) -lkwalletclient -lqt-mt \
-L/usr/X11R6/lib$(ARC) \
-L/usr/lib/qt3/lib$(ARC) -lqt-mt \
-Wl,-soname -Wl,lib$(TARGET).so.$(PROD_NUM) \
-o $(LIBDIR)$(XTRA)/lib$(TARGET).so.$(BLD_VER) \
-L$(LIBDIR)$(XTRA) \
$(OBJDIR)*.$(O)

View File

@@ -0,0 +1,2 @@
OBJS=\
kwallets_rw.$(O)

4
adlib/ad_kw/objs.lux Normal file
View File

@@ -0,0 +1,4 @@
OBJS=\
AssemblyInfo\
KWalletEnum\
KWalletNative

4
adlib/ad_kw/src.lux Normal file
View File

@@ -0,0 +1,4 @@
SRC=\
AssemblyInfo.cs\
KWalletEnum.cs\
KWalletNative.cs