Moving micasa 1.5 trunk to Novell forge.
This commit is contained in:
20
c_adlib/ad_gk/native/Makefile
Normal file
20
c_adlib/ad_gk/native/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# configure environment
|
||||
#
|
||||
TARGET = ad_gk
|
||||
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
|
||||
237
c_adlib/ad_gk/native/ad_gk.c
Normal file
237
c_adlib/ad_gk/native/ad_gk.c
Normal file
@@ -0,0 +1,237 @@
|
||||
#include "ad_gk.h"
|
||||
|
||||
void ListKeyringsCb (GnomeKeyringResult result,
|
||||
GList *keyrings,
|
||||
gpointer data)
|
||||
{
|
||||
GList *l = NULL;
|
||||
char *name = NULL;
|
||||
GList **retList = data;
|
||||
|
||||
GetKeyringsCbData *cbData = data;
|
||||
GMainLoop *loop = cbData->loop;
|
||||
retList = cbData->keyringList;
|
||||
*retList = NULL;
|
||||
|
||||
if (result != GNOME_KEYRING_RESULT_OK)
|
||||
{
|
||||
g_print ("Unable to get keyring list - %d\n", result);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (l = keyrings; l != NULL; l = l->next)
|
||||
{
|
||||
name = l->data;
|
||||
*retList = g_list_append (*retList, g_strdup (name));
|
||||
}
|
||||
}
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
void KeyringGetInfoCb(GnomeKeyringResult result,
|
||||
GnomeKeyringInfo *info,
|
||||
gpointer data)
|
||||
{
|
||||
GetKeyringInfoCbData *cbData = data;
|
||||
KeyringInfo *retInfo = cbData->info;
|
||||
if (result != GNOME_KEYRING_RESULT_OK)
|
||||
{
|
||||
g_print ("Unable to get keyring info %d\n", result);
|
||||
}
|
||||
else
|
||||
{
|
||||
retInfo->lockOnIdle = gnome_keyring_info_get_lock_on_idle(info);
|
||||
retInfo->lockTimeout = gnome_keyring_info_get_lock_timeout(info);
|
||||
retInfo->mTime = gnome_keyring_info_get_mtime(info);
|
||||
retInfo->cTime = gnome_keyring_info_get_ctime(info);
|
||||
retInfo->isLocked = gnome_keyring_info_get_is_locked(info);
|
||||
}
|
||||
g_main_loop_quit (cbData->loop);
|
||||
}
|
||||
|
||||
void ListItemCb( GnomeKeyringResult result,
|
||||
GList *list,
|
||||
gpointer data)
|
||||
{
|
||||
GList **retList;
|
||||
GetItemsCbData *cbData = data;
|
||||
retList = cbData->itemList;
|
||||
*retList = NULL;
|
||||
|
||||
if (result != GNOME_KEYRING_RESULT_OK)
|
||||
{
|
||||
g_print ("Unable to get list of items : %d\n", result);
|
||||
}
|
||||
else
|
||||
{
|
||||
*retList = g_list_copy (list);
|
||||
}
|
||||
|
||||
g_main_loop_quit (cbData->loop);
|
||||
}
|
||||
|
||||
void ItemGetInfoCb( GnomeKeyringResult result,
|
||||
GnomeKeyringItemInfo *info,
|
||||
gpointer data)
|
||||
{
|
||||
GetItemInfoCbData *cbData = data;
|
||||
ItemInfo *itemInfo = cbData->info;
|
||||
if (result != GNOME_KEYRING_RESULT_OK)
|
||||
{
|
||||
g_print ("Unable to get Item info: %d\n", result);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemInfo->itemType = gnome_keyring_item_info_get_type(info);
|
||||
strcpy(itemInfo->displayName,gnome_keyring_item_info_get_display_name(info));
|
||||
strcpy(itemInfo->secret,gnome_keyring_item_info_get_secret(info));
|
||||
itemInfo->mTime = gnome_keyring_item_info_get_mtime(info);
|
||||
itemInfo->cTime = gnome_keyring_item_info_get_ctime(info);
|
||||
|
||||
}
|
||||
g_main_loop_quit (cbData->loop);
|
||||
}
|
||||
|
||||
void ItemGetAttributesCb(GnomeKeyringResult result,
|
||||
GnomeKeyringAttributeList *attributes,
|
||||
gpointer data)
|
||||
{
|
||||
GnomeKeyringAttribute *attrList = NULL;
|
||||
int i = 0;
|
||||
GetAttributeListCbData *cbData = data;
|
||||
|
||||
Attribute *attr = NULL;
|
||||
GList **retList;
|
||||
|
||||
retList = cbData->attrList;
|
||||
*retList = NULL;
|
||||
|
||||
if( result != GNOME_KEYRING_RESULT_OK )
|
||||
{
|
||||
g_print("Unable to get the attributes of item\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
attrList = (GnomeKeyringAttribute*)(attributes->data); //GArray has len and data
|
||||
for(i = 0; i < attributes->len; i++ )
|
||||
{
|
||||
if(attrList[i].type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING)
|
||||
{
|
||||
attr = (Attribute*)malloc(sizeof(Attribute));
|
||||
|
||||
if( NULL != attr )
|
||||
{
|
||||
memset(attr,0,sizeof(Attribute));
|
||||
attr->type = 0;
|
||||
attr->key = (char*)malloc(KEY_SIZE);
|
||||
if(attr->key != NULL)
|
||||
strcpy(attr->key,attrList[i].name);
|
||||
attr->value = (char*)malloc(VAL_SIZE);
|
||||
if(attr->value != NULL)
|
||||
strcpy(attr->value,attrList[i].value.string);
|
||||
}
|
||||
}
|
||||
else if(attrList[i].type == GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32)
|
||||
{
|
||||
attr = (Attribute*)malloc(sizeof(Attribute));
|
||||
if( NULL != attr )
|
||||
{
|
||||
memset(attr,0,sizeof(Attribute));
|
||||
attr->type = 0;
|
||||
attr->key = (char*)malloc(KEY_SIZE);
|
||||
if(attr->key != NULL)
|
||||
strcpy(attr->key,attrList[i].name);
|
||||
attr->value = (char*)malloc(VAL_SIZE);
|
||||
if(attr->value != NULL)
|
||||
sprintf(attr->value,"%d",attrList[i].value.integer);
|
||||
}
|
||||
}
|
||||
*retList = g_list_append (*retList, attr);
|
||||
}
|
||||
}
|
||||
g_main_loop_quit (cbData->loop);
|
||||
}
|
||||
|
||||
int GetKeyrings(GList **keyringList)
|
||||
{
|
||||
GList *l = NULL;
|
||||
|
||||
GetKeyringsCbData cbData;
|
||||
cbData.loop = g_main_loop_new (NULL, FALSE);
|
||||
cbData.keyringList = keyringList;
|
||||
|
||||
gnome_keyring_list_keyring_names(ListKeyringsCb,&cbData,NULL);
|
||||
g_main_loop_run(cbData.loop);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int GetKeyringInfo(char *keyring,KeyringInfo *info)
|
||||
{
|
||||
GetKeyringInfoCbData cbData;
|
||||
|
||||
cbData.loop = g_main_loop_new (NULL, FALSE);
|
||||
cbData.info = info;
|
||||
|
||||
gnome_keyring_get_info(keyring, KeyringGetInfoCb,&cbData, NULL);
|
||||
g_main_loop_run (cbData.loop);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int GetItems(char *keyring, GList **itemList)
|
||||
{
|
||||
GList *l = NULL;
|
||||
gint itemId;
|
||||
GetItemsCbData cbData;
|
||||
cbData.loop = g_main_loop_new (NULL, FALSE);
|
||||
cbData.itemList = itemList;
|
||||
|
||||
gnome_keyring_list_item_ids(keyring, ListItemCb, &cbData, NULL);
|
||||
g_main_loop_run (cbData.loop);
|
||||
return SUCCESS;
|
||||
}
|
||||
int GetItemInfo(char *keyring, int itemId, ItemInfo *info)
|
||||
{
|
||||
GetItemInfoCbData cbData;
|
||||
cbData.loop = g_main_loop_new (NULL, FALSE);
|
||||
cbData.info = info;
|
||||
|
||||
gnome_keyring_item_get_info (keyring,itemId, ItemGetInfoCb,
|
||||
&cbData, NULL);
|
||||
g_main_loop_run (cbData.loop);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int GetAttributeList(char *keyring, int itemId, GList **attrList)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
GetAttributeListCbData cbData;
|
||||
cbData.loop = g_main_loop_new (NULL, FALSE);
|
||||
cbData.attrList = attrList;
|
||||
|
||||
gnome_keyring_item_get_attributes (keyring, itemId,
|
||||
ItemGetAttributesCb, &cbData,
|
||||
NULL);
|
||||
g_main_loop_run (cbData.loop);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int FreeAttributeList(GList *attrList)
|
||||
{
|
||||
GList *l;
|
||||
Attribute *attr = NULL;
|
||||
for(l = attrList; l != NULL; l = l->next)
|
||||
{
|
||||
attr = (Attribute*)(l->data);
|
||||
if(attr->key)
|
||||
{
|
||||
free(attr->key);
|
||||
}
|
||||
if(attr->value)
|
||||
{
|
||||
free(attr->value);
|
||||
}
|
||||
}
|
||||
g_list_free(attrList);
|
||||
return SUCCESS;
|
||||
}
|
||||
76
c_adlib/ad_gk/native/ad_gk.h
Normal file
76
c_adlib/ad_gk/native/ad_gk.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef _AD_GK_H_
|
||||
#define _AD_GK_H_
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <glib.h>
|
||||
#include <gnome-keyring.h>
|
||||
|
||||
#define SUCCESS 0
|
||||
#define FAILURE -1
|
||||
|
||||
#define KEY_SIZE 128
|
||||
#define VAL_SIZE 128
|
||||
|
||||
typedef struct _KeyringInfo
|
||||
{
|
||||
int32_t lockOnIdle;
|
||||
uint32_t lockTimeout;
|
||||
uint32_t mTime;
|
||||
uint32_t cTime;
|
||||
int32_t isLocked;
|
||||
}KeyringInfo;
|
||||
|
||||
typedef struct _ItemInfo
|
||||
{
|
||||
int32_t itemType;
|
||||
char *displayName;
|
||||
char *secret;
|
||||
uint32_t mTime;
|
||||
uint32_t cTime;
|
||||
}ItemInfo;
|
||||
|
||||
typedef struct _Attribute
|
||||
{
|
||||
uint32_t type;
|
||||
char *key;
|
||||
char *value;
|
||||
}Attribute;
|
||||
|
||||
|
||||
int GetKeyrings(GList **retList);
|
||||
int GetKeyringInfo(char *keyring,KeyringInfo *info);
|
||||
int GetItems(char *keyring, GList **itemList);
|
||||
int GetItemInfo(char *keyring, int itemId, ItemInfo *info);
|
||||
int GetAttributeList(char *keyring, int itemId, GList **);
|
||||
int FreeAttributeList(GList *attrList);
|
||||
|
||||
typedef struct _GetKeyringsCbData
|
||||
{
|
||||
GList **keyringList;
|
||||
GMainLoop *loop;
|
||||
}GetKeyringsCbData;
|
||||
|
||||
typedef struct _GetKeyringInfoCbData
|
||||
{
|
||||
KeyringInfo *info;
|
||||
GMainLoop *loop;
|
||||
}GetKeyringInfoCbData;
|
||||
|
||||
typedef struct _GetItemsCbData
|
||||
{
|
||||
GList **itemList;
|
||||
GMainLoop *loop;
|
||||
}GetItemsCbData;
|
||||
|
||||
typedef struct _GetItemInfoCbData
|
||||
{
|
||||
ItemInfo *info;
|
||||
GMainLoop *loop;
|
||||
}GetItemInfoCbData;
|
||||
|
||||
typedef struct _GetAttributeListCbData
|
||||
{
|
||||
GList **attrList;
|
||||
GMainLoop *loop;
|
||||
}GetAttributeListCbData;
|
||||
#endif
|
||||
13
c_adlib/ad_gk/native/link.lux
Normal file
13
c_adlib/ad_gk/native/link.lux
Normal file
@@ -0,0 +1,13 @@
|
||||
LINK = $(CPP) \
|
||||
-Wl,-Bsymbolic \
|
||||
-shared \
|
||||
-pthread\
|
||||
-O2 -fno-exceptions -fno-check-new\
|
||||
-Wl,-rpath -Wl,/usr/lib$(ARCH_LIB) \
|
||||
-L/usr/lib$(ARCH_LIB) -lpthread -lc -ldl \
|
||||
-Wl,-soname -Wl,lib$(TARGET).so.$(PROD_NUM) \
|
||||
-o $(LIBDIR)$(XTRA)/lib$(TARGET).so.$(BLD_VER) \
|
||||
-L$(LIBDIR)$(XTRA) \
|
||||
$(OBJDIR)*.$(O) `pkg-config --libs gnome-keyring-1` -lgnome-keyring \
|
||||
`pkg-config --libs glib-2.0` -lglib-2.0
|
||||
|
||||
2
c_adlib/ad_gk/native/objs.lux
Normal file
2
c_adlib/ad_gk/native/objs.lux
Normal file
@@ -0,0 +1,2 @@
|
||||
OBJS=\
|
||||
ad_gk.$(O)
|
||||
Reference in New Issue
Block a user