aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-dispatch-operation.h
blob: f199be5213afea9cdc121a339a53c626f0ed697a (plain) (blame)
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
124
125
126
127
128
129
130
/*
 * empathy-dispatch-operation.h - Header for EmpathyDispatchOperation
 * Copyright (C) 2008 Collabora Ltd.
 * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
 *
 * 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; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * 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
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef __EMPATHY_DISPATCH_OPERATION_H__
#define __EMPATHY_DISPATCH_OPERATION_H__

#include <glib-object.h>

#include <libempathy/empathy-contact.h>
#include <telepathy-glib/connection.h>
#include <telepathy-glib/channel.h>

G_BEGIN_DECLS

typedef struct _EmpathyDispatchOperation EmpathyDispatchOperation;
typedef struct _EmpathyDispatchOperationClass EmpathyDispatchOperationClass;

struct _EmpathyDispatchOperationClass {
    GObjectClass parent_class;
};

struct _EmpathyDispatchOperation {
    GObject parent;
};

typedef enum {
    /* waiting for the channel information to be ready */
    EMPATHY_DISPATCHER_OPERATION_STATE_PREPARING = 0,
    /* Information gathered ready to be dispatched */
    EMPATHY_DISPATCHER_OPERATION_STATE_PENDING,
    /* Send to approving bits for approval */
    EMPATHY_DISPATCHER_OPERATION_STATE_APPROVING,
    /* Send to handlers for dispatching */
    EMPATHY_DISPATCHER_OPERATION_STATE_DISPATCHING,
    /* somebody claimed the channel */
    EMPATHY_DISPATCHER_OPERATION_STATE_CLAIMED,
    /* dispatch operation invalidated, underlying channel died */
    EMPATHY_DISPATCHER_OPERATION_STATE_INVALIDATED,
} EmpathyDispatchOperationState;

GType empathy_dispatch_operation_get_type (void);

/* TYPE MACROS */
#define EMPATHY_TYPE_DISPATCH_OPERATION \
  (empathy_dispatch_operation_get_type ())
#define EMPATHY_DISPATCH_OPERATION(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_DISPATCH_OPERATION, \
    EmpathyDispatchOperation))
#define EMPATHY_DISPATCH_OPERATION_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_DISPATCH_OPERATION, \
  EmpathyDispatchOperationClass))
#define EMPATHY_IS_DISPATCH_OPERATION(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_DISPATCH_OPERATION))
#define EMPATHY_IS_DISPATCH_OPERATION_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_DISPATCH_OPERATION))
#define EMPATHY_DISPATCH_OPERATION_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_DISPATCH_OPERATION, \
  EmpathyDispatchOperationClass))

EmpathyDispatchOperation *empathy_dispatch_operation_new (
  TpConnection *connection, TpChannel *channel, EmpathyContact *contact,
  gboolean incoming,
  gint64 user_action_time);

EmpathyDispatchOperation *empathy_dispatch_operation_new_with_wrapper (
  TpConnection *connection, TpChannel *channel, EmpathyContact *contact,
  gboolean incoming,
  gint64 user_action_time,
  GObject *channel_wrapper);

/* Start the dispatching process, goes to the APPROVING state for incoming
 * channels and DISPATCHING for outgoing ones */
void empathy_dispatch_operation_start (EmpathyDispatchOperation *operation);

void empathy_dispatch_operation_approve (EmpathyDispatchOperation *operation);

/* Returns whether or not the operation was successfully claimed */
gboolean empathy_dispatch_operation_claim (EmpathyDispatchOperation *operation);

TpChannel *empathy_dispatch_operation_get_channel (
  EmpathyDispatchOperation *operation);

GObject *empathy_dispatch_operation_get_channel_wrapper (
  EmpathyDispatchOperation *operation);

TpConnection *empathy_dispatch_operation_get_tp_connection (
  EmpathyDispatchOperation *operation);

const gchar *empathy_dispatch_operation_get_channel_type (
  EmpathyDispatchOperation *operation);

GQuark empathy_dispatch_operation_get_channel_type_id (
  EmpathyDispatchOperation *operation);

const gchar * empathy_dispatch_operation_get_object_path (
  EmpathyDispatchOperation *operation);

EmpathyDispatchOperationState empathy_dispatch_operation_get_status (
  EmpathyDispatchOperation *operation);

gboolean empathy_dispatch_operation_is_incoming (
  EmpathyDispatchOperation *operation);

void empathy_dispatch_operation_set_user_action_time (
    EmpathyDispatchOperation *self,
    gint64 user_action_time);

gint64 empathy_dispatch_operation_get_user_action_time (
    EmpathyDispatchOperation *self);

G_END_DECLS

#endif /* #ifndef __EMPATHY_DISPATCH_OPERATION_H__*/