SFTP building started.
This commit is contained in:
parent
232bbc0c53
commit
f34af2f6ff
3 changed files with 119 additions and 5 deletions
|
@ -52,6 +52,7 @@ typedef struct SSHS {
|
|||
|
||||
typedef struct SFTPS {
|
||||
SSHT *sshData;
|
||||
void *userData;
|
||||
FILE *local;
|
||||
LIBSSH2_SFTP *session;
|
||||
LIBSSH2_SFTP_HANDLE *handle;
|
||||
|
|
117
src/project.c
117
src/project.c
|
@ -103,7 +103,8 @@ static SectionDataT _sectionData[] = {
|
|||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static ProjectDataT *_cookingProjectData = NULL;
|
||||
static ProjectDataT *_cookingProjectData = NULL;
|
||||
static char **_sendList = NULL;
|
||||
|
||||
|
||||
#define BUILD_SETTINGS_RESPONSE_TEST 1
|
||||
|
@ -132,6 +133,7 @@ EVENT void menuProjectBuildCookRecipes(GtkWidget *object, gpointer user
|
|||
EVENT void menuProjectBuildBuild(GtkWidget *object, gpointer userData);
|
||||
EVENT void menuProjectHelpProject(GtkWidget *object, gpointer userData);
|
||||
static void saveConfig(ProjectDataT *self);
|
||||
static void sendSFTP(SFTPT *sftp);
|
||||
static TargetT **targetArrayCopy(TargetT **targets);
|
||||
static void targetArrayDelete(TargetT ***array);
|
||||
EVENT void treeProjectRowActivated(GtkTreeView *treeView, GtkTreePath *path, GtkTreeViewColumn *column, gpointer userData);
|
||||
|
@ -937,7 +939,86 @@ EVENT void menuProjectBuildCookRecipes(GtkWidget *object, gpointer userData) {
|
|||
|
||||
|
||||
EVENT void menuProjectBuildBuild(GtkWidget *object, gpointer userData) {
|
||||
//***TODO***
|
||||
ProjectDataT *self = (ProjectDataT *)userData;
|
||||
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(self->treeProject));
|
||||
GtkTreeIter iter;
|
||||
GtkTreeIter child;
|
||||
SSHT *ssh;
|
||||
SFTPT *sftp;
|
||||
char *temp;
|
||||
char *filename;
|
||||
char *pathString;
|
||||
char *buildStart;
|
||||
int section;
|
||||
int i;
|
||||
int j;
|
||||
gboolean archPrinted;
|
||||
FILE *out;
|
||||
|
||||
ssh = NEW(SSHT);
|
||||
ssh = sshConnect(self->buildHost, self->buildSSHPort, self->buildUser, self->buildPassword);
|
||||
|
||||
if (!ssh) {
|
||||
message(MSG_ERROR, "Unable to connect to SSH port.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate build.start.
|
||||
buildStart = utilCreateString("%sbuild.start", self->windowData.path);
|
||||
out = fopen(buildStart, "wt");
|
||||
if (!out) {
|
||||
message(MSG_SEVERE, "Unable to write temporary build.start file.");
|
||||
unlink(buildStart); // Just in case.
|
||||
sshDisconnect(&ssh);
|
||||
return;
|
||||
}
|
||||
// Write what we're building.
|
||||
fprintf(out, "application\n"); //***TODO*** We don't know how to handle other types yet.
|
||||
// Write it's title.
|
||||
fprintf(out, "%s\n", "CRAP - MISSING!"); //***TODO*** Collect and remember project name! Derp!
|
||||
// Write desired build targets.
|
||||
for (i=0; i<arrlen(self->targets); i++) {
|
||||
archPrinted = FALSE;
|
||||
for (j=0; j<arrlen(self->targets[i]->archs); j++) {
|
||||
if (self->targets[i]->archs[j]->selected) {
|
||||
if (!archPrinted) {
|
||||
fprintf(out, "%s", self->targets[i]->name);
|
||||
archPrinted = TRUE;
|
||||
}
|
||||
fprintf(out, " %s", self->targets[i]->archs[j]->name);
|
||||
}
|
||||
}
|
||||
if (archPrinted) {
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
}
|
||||
fclose(out);
|
||||
|
||||
// Collect file names to send.
|
||||
gtk_tree_model_get_iter_first(model, &iter);
|
||||
do {
|
||||
if (gtk_tree_model_iter_children(model, &child, &iter)) {
|
||||
do {
|
||||
gtk_tree_model_get(model, &child, COL_FILENAME, &filename, -1);
|
||||
pathString = gtk_tree_model_get_string_from_iter(model, &child);
|
||||
section = atoi(pathString);
|
||||
if (section != SECTION_RAW_DATA) {
|
||||
temp = utilCreateString("%s%s", self->windowData.path, filename);
|
||||
arrput(_sendList, temp);
|
||||
}
|
||||
DEL(filename);
|
||||
} while (gtk_tree_model_iter_next(model, &child));
|
||||
}
|
||||
} while (gtk_tree_model_iter_next(model, &iter));
|
||||
|
||||
// Add build.start to the end.
|
||||
arrput(_sendList, buildStart);
|
||||
|
||||
// Prime the pump! We only set sshData and userData so sendSFTP can determine this is the first file.
|
||||
sftp = NEW(SFTPT);
|
||||
sftp->sshData = ssh;
|
||||
sftp->userData = self;
|
||||
sendSFTP(sftp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1166,6 +1247,38 @@ static gboolean updateBuildOptions(ProjectDataT *self) {
|
|||
}
|
||||
|
||||
|
||||
static void sendSFTP(SFTPT *sftp) {
|
||||
ProjectDataT *self = (ProjectDataT *)sftp->userData;
|
||||
SFTPT *next;
|
||||
char *title;
|
||||
char *target;
|
||||
|
||||
// If source and target are missing, this is the first file - start sending.
|
||||
// Or, did the current transfer succeed? If so, send next file.
|
||||
if ((sftp->source == NULL && sftp->target == NULL) || (sftp->finished && sftp->success)) {
|
||||
// Are there more files to send?
|
||||
if (arrlen(_sendList) > 0) {
|
||||
// Send next entry in the file list.
|
||||
title = utilCreateString("Building %s", self->windowData.filename);
|
||||
target = utilFileBasename(_sendList[0]);
|
||||
sftp = sshSFTPSend(title, sftp->sshData, _sendList[0], target, sendSFTP);
|
||||
DEL(target);
|
||||
DEL(title);
|
||||
arrdel(_sendList, 0);
|
||||
return;
|
||||
} else {
|
||||
// Finished!
|
||||
//***TODO***
|
||||
}
|
||||
}
|
||||
|
||||
// Did the transfer fail?
|
||||
if (sftp->finished && !sftp->success) {
|
||||
//***TODO***
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static TargetT **targetArrayCopy(TargetT **targets) {
|
||||
int i;
|
||||
int j;
|
||||
|
|
|
@ -297,9 +297,9 @@ SFTPT *sshSFTPSend(char *title, SSHT *sshData, char *source, char *target, SFTPC
|
|||
sftp->fileSent = 0;
|
||||
sftp->nread = 0;
|
||||
sftp->ptr = NULL;
|
||||
sftp->title = title;
|
||||
sftp->source = source;
|
||||
sftp->target = target;
|
||||
sftp->title = strdup(title);
|
||||
sftp->source = strdup(source);
|
||||
sftp->target = strdup(target);
|
||||
sftp->sshData = sshData;
|
||||
sftp->uploading = TRUE;
|
||||
sftp->readMore = TRUE;
|
||||
|
|
Loading…
Add table
Reference in a new issue