summaryrefslogtreecommitdiffstats
path: root/python/environs/py_user.c
blob: 5d26b829a779bbc76cf71be0605abae92f7379dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* $Id$ 
 *
 * PyLasso -- Python bindings for Lasso library
 *
 * Copyright (C) 2004 Entr'ouvert
 * http://lasso.labs.libre-entreprise.org
 * 
 * Authors: Valery Febvre <vfebvre@easter-eggs.com>
 *          Nicolas Clapies <nclapies@entrouvert.com>
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "../lassomod.h"

#include "py_user.h"

PyObject *LassoUser_wrap(LassoUser *user) {
  PyObject *ret;

  if (user == NULL) {
    Py_INCREF(Py_None);
    return (Py_None);
  }
  ret = PyCObject_FromVoidPtrAndDesc((void *) user,
                                     (char *) "LassoUser *", NULL);
  return (ret);
}

/******************************************************************************/

PyObject *user_new(PyObject *self, PyObject *args) {
  return (LassoUser_wrap(lasso_user_new()));
}

PyObject *user_new_from_dump(PyObject *self, PyObject *args) {
  LassoUser *user;
  gchar *dump;

  if (CheckArgs(args, "S:user_new_from_dump")) {
    if(!PyArg_ParseTuple(args, (char *) "s:user_new_from_dump", &dump))
      return NULL;
  }
  else return NULL;

  user = lasso_user_new_from_dump(dump);

  return (LassoUser_wrap(user));
}

PyObject *user_dump(PyObject *self, PyObject *args) {
  PyObject  *user_obj;
  gchar     *dump;

  if (CheckArgs(args, "O:user_dump")) {
    if(!PyArg_ParseTuple(args, (char *) "O:user_dump", &user_obj))
      return NULL;
  }
  else return NULL;

  dump = lasso_user_dump(LassoUser_get(user_obj));

  return (charPtrConst_wrap(dump));
}

PyObject *user_get_assertion(PyObject *self, PyObject *args) {
  PyObject  *user_obj;
  LassoNode *assertion_node;
  gchar     *remote_providerID;

  if (CheckArgs(args, "OS:user_get_assertion")) {
    if(!PyArg_ParseTuple(args, (char *) "Os:user_get_assertion", &user_obj, &remote_providerID))
      return NULL;
  }
  else return NULL;

  assertion_node = lasso_user_get_assertion(LassoUser_get(user_obj), remote_providerID);

  return (LassoNode_wrap(assertion_node));
}

PyObject *user_get_next_providerID(PyObject *self, PyObject *args) {
  PyObject  *user_obj;
  gchar     *remote_providerID;

  if (CheckArgs(args, "O:user_get_next_providerID")) {
    if(!PyArg_ParseTuple(args, (char *) "O:user_get_next_providerID", &user_obj, &remote_providerID))
      return NULL;
  }
  else return NULL;

  remote_providerID = lasso_user_get_next_providerID(LassoUser_get(user_obj));

  return (charPtr_wrap(remote_providerID));
}

PyObject *user_remove_assertion(PyObject *self, PyObject *args) {
  PyObject  *user_obj;
  gchar     *remote_providerID;
  int       code;

  if (CheckArgs(args, "OS:user_remove_assertion")) {
    if(!PyArg_ParseTuple(args, (char *) "Os:user_remove_assertion", &user_obj, &remote_providerID))
      return NULL;
  }
  else return NULL;

  code = lasso_user_remove_assertion(LassoUser_get(user_obj), remote_providerID);

  return (int_wrap(code));
}