dacp-share.h 5 KB
Newer Older
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
/*
 * Header for DACP (e.g., iTunes Remote) sharing
 *
 * Copyright (C) 2010 Alexandre Rosenfeld <airmind@gmail.com>
 *
 * 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 __DACP_SHARE_H
#define __DACP_SHARE_H

#include <glib-object.h>

#include <libdmapsharing/dacp-player.h>
#include <libdmapsharing/dmap-share.h>
#include <libdmapsharing/dmap-db.h>
#include <libdmapsharing/dmap-container-db.h>
#include <libdmapsharing/daap-share.h>

G_BEGIN_DECLS
/**
35
 * DACP_TYPE_SHARE:
36 37 38
 *
 * The type for #DACPShare.
 */
39
#define DACP_TYPE_SHARE         (dacp_share_get_type ())
40 41 42 43 44 45 46 47 48
/**
 * DACP_SHARE:
 * @o: Object which is subject to casting.
 * 
 * Casts a #DACPShare or derived pointer into a (DACPShare*) pointer.
 * Depending on the current debugging level, this function may invoke
 * certain runtime checks to identify invalid casts.
 */
#define DACP_SHARE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), \
49
				 DACP_TYPE_SHARE, DACPShare))
50 51 52 53 54 55 56
/**
 * DACP_SHARE_CLASS:
 * @k: a valid #DACPShareClass
 *
 * Casts a derived #DACPShareClass structure into a #DACPShareClass structure.
 */
#define DACP_SHARE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), \
57
				 DACP_TYPE_SHARE, DACPShareClass))
58 59
/**
 * IS_DACP_SHARE:
60
 * @o: Instance to check for being a %DACP_TYPE_SHARE.
61
 * 
62
 * Checks whether a valid #GTypeInstance pointer is of type %DACP_TYPE_SHARE.
63 64
 */
#define IS_DACP_SHARE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
65
				 DACP_TYPE_SHARE))
66 67 68 69 70 71 72 73
/**
 * IS_DACP_SHARE_CLASS:
 * @k: a #DACPShareClass
 * 
 * Checks whether @k "is a" valid #DACPShareClass structure of type
 * %DACP_SHARE or derived.
 */
#define IS_DACP_SHARE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), \
74
				 DACP_TYPE_SHARE))
75 76 77 78 79 80 81 82 83
/**
 * DACP_SHARE_GET_CLASS:
 * @o: a #DACPShare instance.
 * 
 * Get the class structure associated to a #DACPShare instance.
 *
 * Returns: pointer to object class structure.
 */
#define DACP_SHARE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
84
				 DACP_TYPE_SHARE, DACPShareClass))
85 86
typedef struct DACPSharePrivate DACPSharePrivate;

W. Michael Petullo's avatar
W. Michael Petullo committed
87 88
typedef struct
{
89 90 91 92
	DAAPShare daap_share_instance;
	DACPSharePrivate *priv;
} DACPShare;

W. Michael Petullo's avatar
W. Michael Petullo committed
93 94
typedef struct
{
95
	DAAPShareClass daap_share_class;
W. Michael Petullo's avatar
W. Michael Petullo committed
96 97 98 99 100 101 102 103 104

	  gboolean (*lookup_guid) (DACPShare * share, gchar * guid);
	void (*add_guid) (DACPShare * share, gchar * guid);

	void (*remote_found) (DACPShare * share,
			      gchar * service_name, gchar * remote_name);
	void (*remote_lost) (DACPShare * share, gchar * service_name);
	void (*remote_paired) (DACPShare * share,
			       gchar * service_name, gboolean connected);
105 106
} DACPShareClass;

W. Michael Petullo's avatar
W. Michael Petullo committed
107
GType dacp_share_get_type (void);
108 109 110 111 112 113 114 115 116 117 118 119 120 121

/**
 * dacp_share_new:
 * @library_name: The library name that will be shown in the remote.
 * @player: A #DACPPlayer instance, used to retrieve information from a player
 *          implementation.
 * @db: a media database represented by a #DMAPDb instance.
 * @container_db: a container (album) database represented by a #DMAPContainerDb
 *                instance.
 * 
 * Creates a new DACP share and publishes it using mDNS.
 *
 * Returns: a pointer to a #DACPShare.
 */
W. Michael Petullo's avatar
W. Michael Petullo committed
122 123
DACPShare *dacp_share_new (const gchar * library_name, DACPPlayer * player,
			   DMAPDb * db, DMAPContainerDb * container_db);
124 125 126 127 128 129 130 131 132 133 134

/**
 * dacp_share_pair:
 * @share: a #DACPShare 
 * @service_name: DACP client (remote) service identifier.
 * @passcode: 4-Digit PIN code entered by the user.
 * 
 * Pairs a DACP client (Remote) with this server. If the passcode is 
 * correct (the same as shown on the remote), the remote will start connecting
 * to this server.
 */
W. Michael Petullo's avatar
W. Michael Petullo committed
135 136
void dacp_share_pair (DACPShare * share, gchar * service_name,
		      gchar passcode[4]);
137 138 139 140 141 142 143 144 145 146

/**
 * dacp_share_start_lookup:
 * @share: A #DACPShare.
 *     
 * Start looking up for DACP remotes. Connect to #DACPShare::remote-found signal
 * to detect new remotes. Be aware that when a #DACPShare is created, only 
 * after calling this function is that it starts looking up for Remotes on the
 * network.
 */
W. Michael Petullo's avatar
W. Michael Petullo committed
147
void dacp_share_start_lookup (DACPShare * share);
148 149 150 151 152 153 154

/**
 * dacp_share_stop_lookup:
 * @share: A #DACPShare.
 *     
 * Stop looking up for DACP remotes.
 */
W. Michael Petullo's avatar
W. Michael Petullo committed
155
void dacp_share_stop_lookup (DACPShare * share);
156 157 158 159 160 161 162

/**
 * dacp_share_player_update:
 * @share: A #DACPShare.
 * 
 * Signals that the player has been updated (different track playing, playing
 * state changed, suffle state changed, etc).
W. Michael Petullo's avatar
W. Michael Petullo committed
163 164
 */
void dacp_share_player_updated (DACPShare * share);
165 166 167 168

#endif /* __DACP_SHARE_H */

G_END_DECLS