[svn r421] Added libosso library dependencies.
4 * @file gmyth/gmyth_remote_util.c
6 * @brief <p> This component provides utility functions for accessing remote data.
8 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
9 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU Lesser General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "gmyth_remote_util.h"
34 #include "gmyth_recorder.h"
35 #include "gmyth_stringlist.h"
36 #include "gmyth_debug.h"
38 /** Requests the Mythtv backend for a free remote recorder.
40 * @param socket The socket instance where to send the command.
41 * @param curr The recorder index, or -1 to consider the first one.
42 * @return the remote encoder instance available, or NULL if any error happens.
45 remote_request_next_free_recorder (GMythSocket *socket, int curr)
47 GMythRecorder *recorder = NULL;
51 GMythStringList *strlist = gmyth_string_list_new();
53 gmyth_debug ("[%s] Request next free recorder in the backend", __FUNCTION__);
55 gmyth_string_list_append_char_array (strlist, "GET_NEXT_FREE_RECORDER");
56 gmyth_string_list_append_int (strlist, curr);
58 if (!gmyth_socket_sendreceive_stringlist(socket, strlist)) {
59 g_warning ("GET_NEXT_FREE_RECORDER request error!\n");
63 num = gmyth_string_list_get_int (strlist, 0);
64 hostname = gmyth_string_list_get_string (strlist, 1);
65 port = gmyth_string_list_get_int (strlist, 2);
67 if ( num < 0 || port < 0 )
70 gmyth_debug ("[%s] Free recorder info received: num: %d, hostname: %s, port: %d",
71 __FUNCTION__, num, hostname->str, port);
73 recorder = gmyth_recorder_new (num, hostname, port);
77 g_object_unref (strlist);
83 * Requests the Mythtv backend for the number of free remote recorders.
85 * @param socket The socket instance where to send the command.
86 * @return the number of remote encoders instance available, or 0 if no one is actually free..
89 gmyth_remote_util_get_free_recorder_count (GMythSocket *socket)
93 GMythStringList *strlist = gmyth_string_list_new();
95 gmyth_debug ("[%s] Request next free recorder in the backend", __FUNCTION__);
97 gmyth_string_list_append_char_array (strlist, "GET_FREE_RECORDER_COUNT");
99 if (!gmyth_socket_sendreceive_stringlist(socket, strlist)) {
100 gmyth_debug ("GET_FREE_RECORDER_COUNT request error!");
104 num_recs = gmyth_string_list_get_int (strlist, 0);
109 gmyth_debug ("[%s] Free recorder info received: num recorders: %d",
110 __FUNCTION__, num_recs);
114 g_object_unref (strlist);