loudmouth/lm-socket.h
author Frank Zschockelt <lm@freakysoft.de>
Sat, 13 Feb 2016 12:16:45 +0100
changeset 705 1b455131d0f1
parent 690 7ccf2113ec5f
permissions -rw-r--r--
Bumped version to 1.5.3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
516
4dd3aa6b83e5 Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents: 515
diff changeset
     1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
432
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     2
/*
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     3
 * Copyright (C) 2008 Imendio AB
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     4
 *
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     6
 * modify it under the terms of the GNU Lesser General Public License as
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     7
 * published by the Free Software Foundation; either version 2 of the
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     8
 * License, or (at your option) any later version.
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     9
 *
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    13
 * Lesser General Public License for more details.
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    14
 *
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    15
 * You should have received a copy of the GNU Lesser General Public
690
7ccf2113ec5f Update the postal address of the FSF
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
    16
 * License along with this program; if not, see <https://www.gnu.org/licenses>
432
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    17
 */
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    18
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    19
#ifndef __LM_SOCKET_H__
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    20
#define __LM_SOCKET_H__
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    21
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    22
#include <glib-object.h>
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    23
433
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    24
#include "lm-message.h"
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    25
#include "lm-internals.h"
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    26
432
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    27
G_BEGIN_DECLS
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    28
433
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    29
#define LM_TYPE_SOCKET             (lm_socket_get_type())
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    30
#define LM_SOCKET(o)               (G_TYPE_CHECK_INSTANCE_CAST((o), LM_TYPE_SOCKET, LmSocket))
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    31
#define LM_IS_SOCKET(o)            (G_TYPE_CHECK_INSTANCE_TYPE((o), LM_TYPE_SOCKET))
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    32
#define LM_SOCKET_GET_IFACE(o)     (G_TYPE_INSTANCE_GET_INTERFACE((o), LM_TYPE_SOCKET, LmSocketIface))
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    33
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    34
typedef struct _LmSocket      LmSocket;
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    35
typedef struct _LmSocketIface LmSocketIface;
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    36
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    37
struct _LmSocketIface {
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    38
    GTypeInterface parent;
432
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    39
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    40
    /* <vtable> */
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    41
    void     (*connect)      (LmSocket *socket);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    42
    gboolean (*write)        (LmSocket *socket,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    43
                              gchar    *buf,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    44
                              gsize     len);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    45
    gboolean (*read)         (LmSocket *socket,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    46
                              gchar    *buf,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    47
                              gsize     buf_len,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    48
                              gsize    *read_len);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    49
    void     (*disconnect)   (LmSocket *socket);
432
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    50
};
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    51
434
579db9f99cc5 Worked on the LmSocket interface and added a LmSoupSocket class.
Mikael Hallendal <micke@imendio.com>
parents: 433
diff changeset
    52
typedef void  (*LmSocketCallback)  (LmSocket *socket,
579db9f99cc5 Worked on the LmSocket interface and added a LmSoupSocket class.
Mikael Hallendal <micke@imendio.com>
parents: 433
diff changeset
    53
                                    guint     status_code,
579db9f99cc5 Worked on the LmSocket interface and added a LmSoupSocket class.
Mikael Hallendal <micke@imendio.com>
parents: 433
diff changeset
    54
                                    gpointer  user_data);
579db9f99cc5 Worked on the LmSocket interface and added a LmSoupSocket class.
Mikael Hallendal <micke@imendio.com>
parents: 433
diff changeset
    55
433
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    56
GType          lm_socket_get_type          (void);
432
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    57
433
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    58
LmSocket *     lm_socket_new               (const gchar *host,
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    59
                                            guint        port);
432
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    60
/* Use DNS lookup to find the port and the host */
433
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    61
LmSocket *     lm_socket_new_to_service    (const gchar *service);
432
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    62
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    63
/* All async functions so doesn't make a lot of sense to return anything */
434
579db9f99cc5 Worked on the LmSocket interface and added a LmSoupSocket class.
Mikael Hallendal <micke@imendio.com>
parents: 433
diff changeset
    64
/* Use LmSocketCallback instead of signal for the connect result */
433
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    65
void           lm_socket_connect           (LmSocket    *socket);
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    66
gboolean       lm_socket_write             (LmSocket    *socket,
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    67
                                            gchar       *buf,
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    68
                                            gsize        len);
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    69
gboolean       lm_socket_read              (LmSocket    *socket,
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    70
                                            gchar       *buf,
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    71
                                            gsize        buf_len,
441
b666e4d63a3a Some more work on the soup socket
Mikael Hallendal <micke@imendio.com>
parents: 434
diff changeset
    72
                                            gsize       *read_len);
433
2ed69f025f4a Made LmSocket into an interface and hooked up implementation of it in LmTcpSocket.
Mikael Hallendal <micke@imendio.com>
parents: 432
diff changeset
    73
void           lm_socket_disconnect        (LmSocket    *socket);
432
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    74
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    75
G_END_DECLS
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    76
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    77
#endif /* __LM_SOCKET_H__ */
63a049d146c3 Added basic API for the new LmSocket
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    78