Moving micasa 1.5 trunk to Novell forge.

This commit is contained in:
Cameron (Kamran) Mashayekhi
2005-10-11 19:51:00 +00:00
parent 082db33275
commit efe0a5e13c
691 changed files with 116628 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
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,127 @@
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 = "kwallets_rw";
/*
[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();
/*
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;
}
//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();
}
*/
}
}

20
c_adlib/ad_kw/Makefile Normal file
View File

@@ -0,0 +1,20 @@
#
# configure environment
#
TARGET = Novell.CASA.DataEngines.KWallet
CS_NAME = $(TARGET)$(xtra).$(EXE)
include global.mak
include defaults.$(PLAT)
include rules.mak
#
# target object and source files
#
include src.$(PLAT)
include objs.$(PLAT)
#
# targets
#
include target.cs

View File

@@ -0,0 +1,20 @@
#
# configure environment
#
TARGET = kwallets_rw
include global.mak
include defaults.$(PLAT)
include rules.mak
BIN_NAME = $(TARGET)$(xtra).$(BIN)
LIB_NAME = $(TARGET)$(xtra).$(LIB)
#
# target object and source files
#
include objs.$(PLAT)
#
# targets
#
include target.cl

View File

@@ -0,0 +1,49 @@
// -*- 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,389 @@
#include<stdio.h>
#include <kapp.h>
#include <kcmdlineargs.h>
#include<kwallet.h>
#include <dcopclient.h>
using namespace KWallet;
#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()
{
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;
if (wallet->readEntry(key, value)==0)
{
if (value)
{
*secretVal = value;
QDataStream convert(*secretVal, IO_ReadOnly);
if (wallet->entryType(key) == 1 )
{
// Convert the ByteArray to QString
QString passwd;
convert >> passwd;
} 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"
{
struct EnumSecretList *tempEnumSecrets = NULL;
//void MyTest(struct EnumSecretList *enumWalletSecrets)
void Aggregate(struct EnumSecretList *enumWalletSecrets)
{
printf("inside natiove agg");
int retVal = 0;
// struct EnumSecretList *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;
}
*/
}
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;
}
}
}
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;
QDataStream convert(*secretVal, IO_ReadOnly);
QString passwd;
convert >> passwd;
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);
}

View File

@@ -0,0 +1,54 @@
// -*- c++ -*-
#ifndef DCOPIFACEDEMO_H
#define DCOPIFACEDEMO_H
#include <qvbox.h>
/**
* 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);
private:
int ReadKey(Wallet*, QString, QByteArray*);
};
#endif

View File

@@ -0,0 +1,108 @@
/****************************************************************************
** DCOPDemoWidget meta object code from reading C++ file 'casa_dcop.h'
**
** Created: Wed Mar 23 15:53:55 2005
** by: The Qt MOC ($Id: qt/moc_yacc.cpp 3.3.1 edited Feb 18 14:21 $)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#undef QT_NO_COMPAT
//#include "mytest.h"
#include "casa_dcop.h"
#include <qmetaobject.h>
#include <qapplication.h>
#include <private/qucomextra_p.h>
#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != 26)
#error "This file was generated using the moc from 3.3.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
const char *DCOPDemoWidget::className() const
{
return "DCOPDemoWidget";
}
QMetaObject *DCOPDemoWidget::metaObj = 0;
static QMetaObjectCleanUp cleanUp_DCOPDemoWidget( "DCOPDemoWidget", &DCOPDemoWidget::staticMetaObject );
#ifndef QT_NO_TRANSLATION
QString DCOPDemoWidget::tr( const char *s, const char *c )
{
if ( qApp )
return qApp->translate( "DCOPDemoWidget", s, c, QApplication::DefaultCodec );
else
return QString::fromLatin1( s );
}
#ifndef QT_NO_TRANSLATION_UTF8
QString DCOPDemoWidget::trUtf8( const char *s, const char *c )
{
if ( qApp )
return qApp->translate( "DCOPDemoWidget", s, c, QApplication::UnicodeUTF8 );
else
return QString::fromUtf8( s );
}
#endif // QT_NO_TRANSLATION_UTF8
#endif // QT_NO_TRANSLATION
QMetaObject* DCOPDemoWidget::staticMetaObject()
{
if ( metaObj )
return metaObj;
QMetaObject* parentObject = QObject::staticMetaObject();
static const QUMethod slot_0 = {"dump", 0, 0 };
// static const QUMethod slot_1 = {"getKWalletSecret", 0, 0 };
// static const QUMethod slot_2 = {"setKWalletSecret", 0, 0 };
static const QMetaData slot_tbl[] = {
{ "dump()", &slot_0, QMetaData::Public },
// { "getKWalletSecret()", &slot_1, QMetaData::Public },
// { "setKWalletSecret()", &slot_2, QMetaData::Public }
};
metaObj = QMetaObject::new_metaobject(
"DCOPDemoWidget", parentObject,
slot_tbl, 3,
0, 0,
#ifndef QT_NO_PROPERTIES
0, 0,
0, 0,
#endif // QT_NO_PROPERTIES
0, 0 );
cleanUp_DCOPDemoWidget.setMetaObject( metaObj );
return metaObj;
}
void* DCOPDemoWidget::qt_cast( const char* clname )
{
if ( !qstrcmp( clname, "DCOPDemoWidget" ) )
return this;
return QObject::qt_cast( clname );
}
bool DCOPDemoWidget::qt_invoke( int _id, QUObject* _o )
{
switch ( _id - staticMetaObject()->slotOffset() ) {
case 0: break;//dump(); break;
// case 1: getKWalletSecret(); break;
// case 2: setKWalletSecret(); break;
default:
return QObject::qt_invoke( _id, _o );
}
return TRUE;
}
bool DCOPDemoWidget::qt_emit( int _id, QUObject* _o )
{
return QObject::qt_emit(_id,_o);
}
#ifndef QT_NO_PROPERTIES
bool DCOPDemoWidget::qt_property( int id, int f, QVariant* v)
{
return QObject::qt_property( id, f, v);
}
bool DCOPDemoWidget::qt_static_property( QObject* , int , int , QVariant* ){ return FALSE; }
#endif // QT_NO_PROPERTIES

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 \
-Wl,-soname -Wl,lib$(TARGET).so.$(PROD_NUM) \
-o $(LIBDIR)$(XTRA)/lib$(TARGET).so.$(BLD_VER) \
-L$(LIBDIR)$(XTRA) \
$(OBJDIR)*.$(O) -L/opt/kde3/lib$(ARC) \
-L/usr/X11R6/lib$(ARC) -L/usr/lib/qt3/lib$(ARC) \
-lkwalletclient -lqt-mt

View File

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

3
c_adlib/ad_kw/objs.lux Normal file
View File

@@ -0,0 +1,3 @@
OBJS=\
KWalletEnum\
KWalletNative

3
c_adlib/ad_kw/src.lux Normal file
View File

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