1.1 --- a/gmyth/src/gmyth_jobqueue.c Tue Apr 03 14:58:30 2007 +0100
1.2 +++ b/gmyth/src/gmyth_jobqueue.c Wed May 23 16:11:29 2007 +0100
1.3 @@ -23,7 +23,7 @@
1.4 * along with this program; if not, write to the Free Software
1.5 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.6 */
1.7 -
1.8 +
1.9 #ifdef HAVE_CONFIG_H
1.10 #include "config.h"
1.11 #endif
1.12 @@ -39,12 +39,14 @@
1.13 * @return gboolean - result of connection
1.14 *
1.15 */
1.16 -static GMythSocket*
1.17 -backend_connect (GMythBackendInfo *backend_info)
1.18 +static GMythSocket *
1.19 +backend_connect (GMythBackendInfo * backend_info)
1.20 {
1.21 GMythSocket *socket = gmyth_socket_new ();
1.22 +
1.23 if (gmyth_socket_connect_to_backend (socket,
1.24 - gmyth_backend_info_get_hostname (backend_info),
1.25 + gmyth_backend_info_get_hostname
1.26 + (backend_info),
1.27 gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) {
1.28 gmyth_debug ("Backend socket connection success");
1.29 return socket;
1.30 @@ -66,28 +68,28 @@
1.31 * @return the value returned by the backend
1.32 *
1.33 */
1.34 -static gchar* send_command(GMythSocket *socket, gchar* action,
1.35 - gchar* job, gint chanid, gchar* starttime,
1.36 - gchar* options)
1.37 +static gchar *
1.38 +send_command (GMythSocket * socket, gchar * action,
1.39 + gchar * job, gint chanid, gchar * starttime, gchar * options)
1.40 {
1.41 - GString* command = g_string_new ("");
1.42 - GString* ret_str;
1.43 - gchar* ret;
1.44 + GString *command = g_string_new ("");
1.45 + GString *ret_str;
1.46 + gchar *ret;
1.47
1.48 - GMythStringList *retlist = gmyth_string_list_new();
1.49 + GMythStringList *retlist = gmyth_string_list_new ();
1.50
1.51 - g_string_printf(command, "JOBQUEUE %s %s %d %s %s", action, job,
1.52 - chanid, starttime, options);
1.53 + g_string_printf (command, "JOBQUEUE %s %s %d %s %s", action, job,
1.54 + chanid, starttime, options);
1.55
1.56 gmyth_string_list_append_string (retlist, command);
1.57 gmyth_socket_write_stringlist (socket, retlist);
1.58
1.59 // receive answer
1.60 gmyth_socket_read_stringlist (socket, retlist);
1.61 - ret_str = gmyth_string_list_get_string(retlist, 0);
1.62 + ret_str = gmyth_string_list_get_string (retlist, 0);
1.63
1.64 //ret = ret_str->str;
1.65 - ret = g_string_free( ret_str, FALSE);
1.66 + ret = g_string_free (ret_str, FALSE);
1.67 g_string_free (command, TRUE);
1.68
1.69 gmyth_string_list_clear_all (retlist);
1.70 @@ -104,12 +106,13 @@
1.71 * @return 0 if success and -1 if error
1.72 *
1.73 */
1.74 -static gboolean test_result(gchar* ret, gchar* value)
1.75 +static gboolean
1.76 +test_result (gchar * ret, gchar * value)
1.77 {
1.78 - if (g_ascii_strcasecmp(ret, value) == 0) {
1.79 + if (g_ascii_strcasecmp (ret, value) == 0) {
1.80 return TRUE;
1.81 } else {
1.82 - gmyth_debug("JobQueue Error: %s", ret);
1.83 + gmyth_debug ("JobQueue Error: %s", ret);
1.84 return FALSE;
1.85 }
1.86 }
1.87 @@ -121,30 +124,30 @@
1.88 * @return TRUE if the job was added, FALSE if not
1.89 *
1.90 */
1.91 -gboolean gmyth_jobqueue_add_job (GMythTranscoder* transcode, gchar* job)
1.92 +gboolean
1.93 +gmyth_jobqueue_add_job (GMythTranscoder * transcode, gchar * job)
1.94 {
1.95 GMythSocket *socket = backend_connect (transcode->backend_info);
1.96 gboolean res = FALSE;
1.97
1.98 if (socket != NULL) {
1.99 - GString* options = g_string_new ("");
1.100 - gchar* ret = NULL;
1.101 + GString *options = g_string_new ("");
1.102 + gchar *ret = NULL;
1.103
1.104 - if (g_ascii_strcasecmp(job, "JOB_TRANSCODE") == 0)
1.105 - {
1.106 + if (g_ascii_strcasecmp (job, "JOB_TRANSCODE") == 0) {
1.107 if (transcode->cutlist)
1.108 - g_string_append(options, " JOB_USE_CUTLIST");
1.109 + g_string_append (options, " JOB_USE_CUTLIST");
1.110
1.111 if (transcode->output)
1.112 - g_string_append_printf(options, " JOB_OUTPUT %s",\
1.113 - transcode->output_filename);
1.114 + g_string_append_printf (options, " JOB_OUTPUT %s",
1.115 + transcode->output_filename);
1.116
1.117 if (transcode->profile != NULL)
1.118 - g_string_append_printf(options, " %s", transcode->profile);
1.119 + g_string_append_printf (options, " %s", transcode->profile);
1.120 }
1.121 - ret = send_command(socket, "ADD", job, transcode->chanid,
1.122 - transcode->starttime, options->str);
1.123 - res = test_result(ret, "JOBQUEUE_OK");
1.124 + ret = send_command (socket, "ADD", job, transcode->chanid,
1.125 + transcode->starttime, options->str);
1.126 + res = test_result (ret, "JOBQUEUE_OK");
1.127 gmyth_socket_close_connection (socket);
1.128
1.129 g_object_unref (socket);
1.130 @@ -155,7 +158,7 @@
1.131 g_free (ret);
1.132
1.133 } else {
1.134 - gmyth_debug("JobQueue Connection Failed");
1.135 + gmyth_debug ("JobQueue Connection Failed");
1.136 }
1.137
1.138 return res;
1.139 @@ -169,26 +172,27 @@
1.140 * @return the value of the key
1.141 *
1.142 */
1.143 -gboolean gmyth_jobqueue_change_cmd (GMythTranscoder* transcode, gchar* action,
1.144 - gchar* job)
1.145 +gboolean
1.146 +gmyth_jobqueue_change_cmd (GMythTranscoder * transcode, gchar * action,
1.147 + gchar * job)
1.148 {
1.149 - GMythSocket *socket = backend_connect(transcode->backend_info);
1.150 + GMythSocket *socket = backend_connect (transcode->backend_info);
1.151 gboolean res = FALSE;
1.152
1.153 if (socket != NULL) {
1.154 - gchar* ret = send_command(socket, action, job,
1.155 - transcode->chanid,
1.156 - transcode->starttime, "");
1.157 + gchar *ret = send_command (socket, action, job,
1.158 + transcode->chanid,
1.159 + transcode->starttime, "");
1.160
1.161 - res = test_result(ret, "JOBQUEUE_CHANGED_CMD_OK");
1.162 + res = test_result (ret, "JOBQUEUE_CHANGED_CMD_OK");
1.163
1.164 - gmyth_socket_close_connection (socket);
1.165 + gmyth_socket_close_connection (socket);
1.166 g_object_unref (socket);
1.167
1.168 - g_free(ret);
1.169 + g_free (ret);
1.170
1.171 } else {
1.172 - gmyth_debug("JobQueue Connection Failed");
1.173 + gmyth_debug ("JobQueue Connection Failed");
1.174 }
1.175
1.176 return res;