mms_connman.h 2.22 KB
Newer Older
Slava Monich's avatar
Slava Monich committed
1
/*
2
 * Copyright (C) 2013-2016 Jolla Ltd.
Slava Monich's avatar
Slava Monich committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * 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.
 *
 */

#ifndef JOLLA_MMS_CONNMAN_H
#define JOLLA_MMS_CONNMAN_H

#include "mms_lib_types.h"

20 21 22
/* Instance */
struct mms_connman {
    GObject object;
23
    int busy;
24 25 26
};

/* Class */
Slava Monich's avatar
Slava Monich committed
27 28
typedef struct mms_connman_class {
    GObjectClass parent;
29
    char* (*fn_default_imsi)(MMSConnMan* cm);
Slava Monich's avatar
Slava Monich committed
30 31 32 33 34 35 36
    MMSConnection* (*fn_open_connection)(MMSConnMan* cm, const char* imsi,
        gboolean user_request);
} MMSConnManClass;

GType mms_connman_get_type(void);
#define MMS_TYPE_CONNMAN (mms_connman_get_type())

37 38 39 40 41 42
/* Connman event callback */
typedef void
(*mms_connman_event_fn)(
    MMSConnMan* cm,
    void* param);

Slava Monich's avatar
Slava Monich committed
43 44 45 46 47 48 49 50 51
/* Reference counting */
MMSConnMan*
mms_connman_ref(
    MMSConnMan* cm);

void
mms_connman_unref(
    MMSConnMan* cm);

52 53 54 55 56 57 58 59
/**
 * Returns default (first available) IMSI or NULL if SIM is not present
 * or not configured. Caller must g_free() the returned string.
 */
char*
mms_connman_default_imsi(
    MMSConnMan* cm);

Slava Monich's avatar
Slava Monich committed
60 61 62 63 64 65 66 67 68 69
/**
 * Creates a new connection or returns the reference to an aready active one.
 * The caller must release the reference.
 */
MMSConnection*
mms_connman_open_connection(
    MMSConnMan* cm,
    const char* imsi,
    gboolean user_request);

70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
/**
 * While busy flags is on, mms-engine shouldn't exit
 */
void
mms_connman_busy_update(
    MMSConnMan* cm,
    int change);

gulong
mms_connman_add_done_callback(
    MMSConnMan* cm,
    mms_connman_event_fn fn,
    void* param);

void
mms_connman_remove_callback(
    MMSConnMan* cm,
    gulong handler_id);

#define mms_connman_busy(cm) ((cm) && ((cm)->busy > 0))
#define mms_connman_busy_inc(cm) mms_connman_busy_update(cm,1)
#define mms_connman_busy_dec(cm) mms_connman_busy_update(cm,-1)

Slava Monich's avatar
Slava Monich committed
93 94 95 96 97 98 99 100 101
#endif /* JOLLA_MMS_CONNMAN_H */

/*
 * Local Variables:
 * mode: C
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 */