1 /*
2  * Header for DACP (e.g., iTunes Remote) sharing
3  *
4  * Copyright (C) 2010 Alexandre Rosenfeld <airmind@gmail.com>
5  *
6  * This library 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  * This library 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 this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21 
22 #ifndef __DACP_SHARE_H
23 #define __DACP_SHARE_H
24 
25 #include <glib-object.h>
26 
27 #include <libdmapsharing/dacp-player.h>
28 #include <libdmapsharing/dmap-share.h>
29 #include <libdmapsharing/dmap-db.h>
30 #include <libdmapsharing/dmap-container-db.h>
31 #include <libdmapsharing/daap-share.h>
32 
33 G_BEGIN_DECLS
34 /**
35  * DACP_TYPE_SHARE:
36  *
37  * The type for #DACPShare.
38  */
39 #define DACP_TYPE_SHARE         (dacp_share_get_type ())
40 /**
41  * DACP_SHARE:
42  * @o: Object which is subject to casting.
43  *
44  * Casts a #DACPShare or derived pointer into a (DACPShare*) pointer.
45  * Depending on the current debugging level, this function may invoke
46  * certain runtime checks to identify invalid casts.
47  */
48 #define DACP_SHARE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), \
49 				 DACP_TYPE_SHARE, DACPShare))
50 /**
51  * DACP_SHARE_CLASS:
52  * @k: a valid #DACPShareClass
53  *
54  * Casts a derived #DACPShareClass structure into a #DACPShareClass structure.
55  */
56 #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  * IS_DACP_SHARE_CLASS:
68  * @k: a #DACPShareClass
69  *
70  * Checks whether @k "is a" valid #DACPShareClass structure of type
71  * %DACP_SHARE or derived.
72  */
73 #define IS_DACP_SHARE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), \
74 				 DACP_TYPE_SHARE))
75 /**
76  * DACP_SHARE_GET_CLASS:
77  * @o: a #DACPShare instance.
78  *
79  * Get the class structure associated to a #DACPShare instance.
80  *
81  * Returns: pointer to object class structure.
82  */
83 #define DACP_SHARE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
84 				 DACP_TYPE_SHARE, DACPShareClass))
85 typedef struct DACPSharePrivate DACPSharePrivate;
86 
87 typedef struct
88 {
89 	DAAPShare daap_share_instance;
90 	DACPSharePrivate *priv;
91 } DACPShare;
92 
93 typedef struct
94 {
95 	DAAPShareClass daap_share_class;
96 
97 	  gboolean (*lookup_guid) (DACPShare * share, gchar * guid);
98 	void (*add_guid) (DACPShare * share, gchar * guid);
99 
100 	void (*remote_found) (DACPShare * share,
101 			      gchar * service_name, gchar * remote_name);
102 	void (*remote_lost) (DACPShare * share, gchar * service_name);
103 	void (*remote_paired) (DACPShare * share,
104 			       gchar * service_name, gboolean connected);
105 } DACPShareClass;
106 
107 GType dacp_share_get_type (void);
108 
109 /**
110  * dacp_share_new:
111  * @library_name: The library name that will be shown in the remote.
112  * @player: A #DACPPlayer instance, used to retrieve information from a player
113  *          implementation.
114  * @db: a media database represented by a #DMAPDb instance.
115  * @container_db: a container (album) database represented by a #DMAPContainerDb
116  *                instance.
117  *
118  * Creates a new DACP share and publishes it using mDNS.
119  *
120  * Returns: a pointer to a #DACPShare.
121  */
122 DACPShare *dacp_share_new (const gchar * library_name, DACPPlayer * player,
123 			   DMAPDb * db, DMAPContainerDb * container_db);
124 
125 /**
126  * dacp_share_pair:
127  * @share: a #DACPShare
128  * @service_name: DACP client (remote) service identifier.
129  * @passcode: 4-Digit PIN code entered by the user.
130  *
131  * Pairs a DACP client (Remote) with this server. If the passcode is
132  * correct (the same as shown on the remote), the remote will start connecting
133  * to this server.
134  */
135 void dacp_share_pair (DACPShare * share, gchar * service_name,
136 		      gchar passcode[4]);
137 
138 /**
139  * dacp_share_start_lookup:
140  * @share: A #DACPShare.
141  *
142  * Start looking up for DACP remotes. Connect to #DACPShare::remote-found signal
143  * to detect new remotes. Be aware that when a #DACPShare is created, only
144  * after calling this function is that it starts looking up for Remotes on the
145  * network.
146  */
147 void dacp_share_start_lookup (DACPShare * share);
148 
149 /**
150  * dacp_share_stop_lookup:
151  * @share: A #DACPShare.
152  *
153  * Stop looking up for DACP remotes.
154  */
155 void dacp_share_stop_lookup (DACPShare * share);
156 
157 /**
158  * dacp_share_player_update:
159  * @share: A #DACPShare.
160  *
161  * Signals that the player has been updated (different track playing, playing
162  * state changed, suffle state changed, etc).
163  */
164 void dacp_share_player_updated (DACPShare * share);
165 
166 #endif /* __DACP_SHARE_H */
167 
168 G_END_DECLS
169