Commit 1e962ef0 authored by Nedko Arnaudov's avatar Nedko Arnaudov
Browse files

Move session command reply array creation to JackSessionNotifyResult

This eliminates code duplication in JackWinNamedPipeClientChannel and
JackSocketClientChannel.
parent 80d316ec
......@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "types.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <list>
namespace Jack
......@@ -1188,6 +1189,26 @@ struct JackSessionNotifyResult : public JackResult
return 0;
}
jack_session_command_t* GetCommands()
{
jack_session_command_t* session_command = (jack_session_command_t *)malloc(sizeof(jack_session_command_t) * (fCommandList.size() + 1));
int i = 0;
for (std::list<JackSessionCommand>::iterator ci = fCommandList.begin(); ci != fCommandList.end(); ci++) {
session_command[i].uuid = strdup(ci->fUUID);
session_command[i].client_name = strdup(ci->fClientName);
session_command[i].command = strdup(ci->fCommand);
session_command[i].flags = ci->fFlags;
i += 1;
}
session_command[i].uuid = NULL;
session_command[i].client_name = NULL;
session_command[i].command = NULL;
session_command[i].flags = (jack_session_flags_t)0;
return session_command;
}
};
/*!
......
......@@ -259,24 +259,7 @@ void JackSocketClientChannel::SessionNotify(int refnum, const char* target, jack
JackSessionNotifyResult res;
int intresult;
ServerSyncCall(&req, &res, &intresult);
jack_session_command_t* session_command = (jack_session_command_t *)malloc(sizeof(jack_session_command_t) * (res.fCommandList.size() + 1));
int i = 0;
for (std::list<JackSessionCommand>::iterator ci = res.fCommandList.begin(); ci != res.fCommandList.end(); ci++) {
session_command[i].uuid = strdup(ci->fUUID);
session_command[i].client_name = strdup(ci->fClientName);
session_command[i].command = strdup(ci->fCommand);
session_command[i].flags = ci->fFlags;
i += 1;
}
session_command[i].uuid = NULL;
session_command[i].client_name = NULL;
session_command[i].command = NULL;
session_command[i].flags = (jack_session_flags_t)0;
*result = session_command;
*result = res.GetCommands();
}
void JackSocketClientChannel::SessionReply(int refnum, int* result)
......
......@@ -263,24 +263,7 @@ void JackWinNamedPipeClientChannel::SessionNotify(int refnum, const char* target
JackSessionNotifyResult res;
int intresult;
ServerSyncCall(&req, &res, &intresult);
jack_session_command_t* session_command = (jack_session_command_t *)malloc(sizeof(jack_session_command_t) * (res.fCommandList.size() + 1));
int i = 0;
for (std::list<JackSessionCommand>::iterator ci = res.fCommandList.begin(); ci != res.fCommandList.end(); ci++) {
session_command[i].uuid = strdup(ci->fUUID);
session_command[i].client_name = strdup(ci->fClientName);
session_command[i].command = strdup(ci->fCommand);
session_command[i].flags = ci->fFlags;
i += 1;
}
session_command[i].uuid = NULL;
session_command[i].client_name = NULL;
session_command[i].command = NULL;
session_command[i].flags = (jack_session_flags_t)0;
*result = session_command;
*result = res.GetCommands();
}
void JackWinNamedPipeClientChannel::SessionReply(int refnum, int* result)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment