1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-  */
2 /*
3  * libgfbgraph - GObject library for Facebook Graph API
4  * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com>
5  *
6  * GFBGraph is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * GFBGraph is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with GFBGraph.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __GFBGRAPH_NODE_H__
21 #define __GFBGRAPH_NODE_H__
22 
23 #include <glib-object.h>
24 #include <gfbgraph/gfbgraph-authorizer.h>
25 
26 G_BEGIN_DECLS
27 
28 #define GFBGRAPH_TYPE_NODE             (gfbgraph_node_get_type())
29 #define GFBGRAPH_NODE(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),GFBGRAPH_TYPE_NODE,GFBGraphNode))
30 #define GFBGRAPH_NODE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),GFBGRAPH_TYPE_NODE,GFBGraphNodeClass))
31 #define GFBGRAPH_IS_NODE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),GFBGRAPH_TYPE_NODE))
32 #define GFBGRAPH_IS_NODE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),GFBGRAPH_TYPE_NODE))
33 #define GFBGRAPH_NODE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),GFBGRAPH_TYPE_NODE,GFBGraphNodeClass))
34 
35 #define GFBGRAPH_NODE_ERROR            gfbgraph_node_error_quark ()
36 
37 typedef struct _GFBGraphNode        GFBGraphNode;
38 typedef struct _GFBGraphNodeClass   GFBGraphNodeClass;
39 typedef struct _GFBGraphNodePrivate GFBGraphNodePrivate;
40 
41 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GFBGraphNode, g_object_unref)
42 
43 struct _GFBGraphNode {
44         GObject parent;
45 
46         /*< private >*/
47         GFBGraphNodePrivate *priv;
48 };
49 
50 struct _GFBGraphNodeClass {
51         GObjectClass parent_class;
52 };
53 
54 typedef enum {
55         GFBGRAPH_NODE_ERROR_NO_CONNECTIONABLE = 1,
56         GFBGRAPH_NODE_ERROR_NO_CONNECTABLE
57 } GFBGraphNodeError;
58 
59 GType          gfbgraph_node_get_type    (void) G_GNUC_CONST;
60 GQuark         gfbgraph_node_error_quark (void) G_GNUC_CONST;
61 GFBGraphNode*  gfbgraph_node_new         (void);
62 
63 GFBGraphNode*  gfbgraph_node_new_from_id (GFBGraphAuthorizer *authorizer, const gchar *id, GType node_type, GError **error);
64 
65 const gchar*   gfbgraph_node_get_id           (GFBGraphNode *node);
66 const gchar*   gfbgraph_node_get_link         (GFBGraphNode *node);
67 const gchar*   gfbgraph_node_get_created_time (GFBGraphNode *node);
68 const gchar*   gfbgraph_node_get_updated_time (GFBGraphNode *node);
69 
70 void           gfbgraph_node_set_id           (GFBGraphNode *node, const gchar *id);
71 
72 GList*         gfbgraph_node_get_connection_nodes              (GFBGraphNode         *node,
73                                                                 GType                 node_type,
74                                                                 GFBGraphAuthorizer   *authorizer,
75                                                                 GError              **error);
76 void           gfbgraph_node_get_connection_nodes_async        (GFBGraphNode         *node,
77                                                                 GType                 node_type,
78                                                                 GFBGraphAuthorizer   *authorizer,
79                                                                 GCancellable         *cancellable,
80                                                                 GAsyncReadyCallback   callback,
81                                                                 gpointer              user_data);
82 GList*         gfbgraph_node_get_connection_nodes_async_finish (GFBGraphNode         *node,
83                                                                 GAsyncResult         *result,
84                                                                 GError              **error);
85 
86 gboolean       gfbgraph_node_append_connection (GFBGraphNode *node, GFBGraphNode *connect_node, GFBGraphAuthorizer *authorizer, GError **error);
87 
88 G_END_DECLS
89 
90 #endif /* __GFBGRAPH_NODE_H__ */
91