renatofilho@320: /** renatofilho@320: * GMyth Library renatofilho@320: * renatofilho@320: * @file gmyth/gmyth_remote_util.c renatofilho@320: * renatofilho@320: * @brief

This component provides utility functions for accessing remote data. renatofilho@320: * renatofilho@320: * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. renatofilho@320: * @author Hallyson Luiz de Morais Melo renatofilho@320: * renatofilho@320: *//* renatofilho@320: * renatofilho@320: * This program is free software; you can redistribute it and/or modify renatofilho@320: * it under the terms of the GNU Lesser General Public License as published by renatofilho@320: * the Free Software Foundation; either version 2 of the License, or renatofilho@320: * (at your option) any later version. renatofilho@320: * renatofilho@320: * This program is distributed in the hope that it will be useful, renatofilho@320: * but WITHOUT ANY WARRANTY; without even the implied warranty of renatofilho@320: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the renatofilho@320: * GNU General Public License for more details. renatofilho@320: * renatofilho@320: * You should have received a copy of the GNU Lesser General Public License renatofilho@320: * along with this program; if not, write to the Free Software renatofilho@320: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA renatofilho@320: */ renatofilho@320: renatofilho@320: #ifdef HAVE_CONFIG_H renatofilho@320: #include "config.h" renatofilho@320: #endif renatofilho@320: renatofilho@320: #include "gmyth_remote_util.h" renatofilho@320: renatofilho@320: #include "gmyth_recorder.h" renatofilho@320: #include "gmyth_stringlist.h" renatofilho@320: #include "gmyth_debug.h" renatofilho@320: renatofilho@320: /** Requests the Mythtv backend for a free remote recorder. renatofilho@320: * renatofilho@320: * @param curr The recorder index, or -1 to consider the first one. renatofilho@320: * @return the remote encoder instance available, or NULL if any error happens. renatofilho@320: */ renatofilho@320: GMythRecorder* renatofilho@320: remote_request_next_free_recorder (GMythSocket *socket, int curr) renatofilho@320: { renatofilho@320: GMythRecorder *recorder = NULL; renatofilho@320: GString *hostname; renatofilho@320: int num, port; renatofilho@320: renatofilho@320: GMythStringList *strlist = gmyth_string_list_new(); renatofilho@320: renatofilho@320: gmyth_debug ("[%s] Request next free recorder in the backend", __FUNCTION__); renatofilho@320: renatofilho@320: gmyth_string_list_append_char_array (strlist, "GET_NEXT_FREE_RECORDER"); renatofilho@320: gmyth_string_list_append_int (strlist, curr); renatofilho@320: renatofilho@320: if (!gmyth_socket_sendreceive_stringlist(socket, strlist)) { renatofilho@320: g_warning ("GET_NEXT_FREE_RECORDER request error!\n"); renatofilho@320: return NULL; renatofilho@320: } renatofilho@320: renatofilho@320: num = gmyth_string_list_get_int (strlist, 0); renatofilho@320: hostname = gmyth_string_list_get_string (strlist, 1); renatofilho@320: port = gmyth_string_list_get_int (strlist, 2); renatofilho@320: renatofilho@320: if ( num < 0 || port < 0 ) renatofilho@320: goto clean_up; renatofilho@320: renatofilho@320: gmyth_debug ("[%s] Free recorder info received: num: %d, hostname: %s, port: %d", renatofilho@320: __FUNCTION__, num, hostname->str, port); renatofilho@320: renatofilho@320: recorder = gmyth_recorder_new (num, hostname, port); renatofilho@320: renatofilho@320: clean_up: renatofilho@320: renatofilho@320: g_object_unref (strlist); renatofilho@320: renatofilho@320: return recorder; renatofilho@320: }