Start of an SFTP uploader.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23317 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -595,6 +595,14 @@ VideoWindow::MessageReceived(BMessage* message)
|
|||||||
message->FindInt32("be:translator", &(fFtpInfo.translator));
|
message->FindInt32("be:translator", &(fFtpInfo.translator));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case msg_upl_client:
|
||||||
|
if (control != NULL) {
|
||||||
|
int32 client;
|
||||||
|
message->FindInt32("client", &(fFtpInfo.uploadClient));
|
||||||
|
FTPINFO("upl client = %d\n", fFtpInfo.uploadClient);//XXX
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case msg_server:
|
case msg_server:
|
||||||
if (control != NULL) {
|
if (control != NULL) {
|
||||||
strncpy(fFtpInfo.serverText, ((BTextControl*)control)->Text(), 64);
|
strncpy(fFtpInfo.serverText, ((BTextControl*)control)->Text(), 64);
|
||||||
@@ -737,7 +745,18 @@ VideoWindow::_BuildCaptureControls(BView* theView)
|
|||||||
aFrame.bottom -= kYBuffer;
|
aFrame.bottom -= kYBuffer;
|
||||||
|
|
||||||
fFtpSetupBox = new BBox(aFrame, "Ftp Setup", B_FOLLOW_ALL, B_WILL_DRAW);
|
fFtpSetupBox = new BBox(aFrame, "Ftp Setup", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
fFtpSetupBox->SetLabel("Ftp Setup");
|
fUploadClientMenu = new BPopUpMenu("Send to...");
|
||||||
|
for (int i = 0; kUploadClient[i]; i++) {
|
||||||
|
BMessage *m = new BMessage(msg_upl_client);
|
||||||
|
m->AddInt32("client", i);
|
||||||
|
fUploadClientMenu->AddItem(new BMenuItem(kUploadClient[i], m));
|
||||||
|
}
|
||||||
|
fUploadClientMenu->SetTargetForItems(this);
|
||||||
|
//fUploadClientMenu->FindItem(fCaptureRateSetting->Value())->SetMarked(true);
|
||||||
|
fUploadClientSelector = new BMenuField(aFrame, "UploadClient", "", fUploadClientMenu);
|
||||||
|
fUploadClientSelector->SetDivider(0.0);
|
||||||
|
|
||||||
|
fFtpSetupBox->SetLabel(fUploadClientSelector);
|
||||||
theView->AddChild(fFtpSetupBox);
|
theView->AddChild(fFtpSetupBox);
|
||||||
|
|
||||||
aFrame = fFtpSetupBox->Bounds();
|
aFrame = fFtpSetupBox->Bounds();
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ enum {
|
|||||||
|
|
||||||
msg_translate = 'tran',
|
msg_translate = 'tran',
|
||||||
|
|
||||||
|
msg_upl_client = 'ucli',
|
||||||
msg_server = 'srvr',
|
msg_server = 'srvr',
|
||||||
msg_login = 'lgin',
|
msg_login = 'lgin',
|
||||||
msg_password = 'pswd',
|
msg_password = 'pswd',
|
||||||
@@ -77,6 +78,13 @@ const char* kCaptureRate[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const char* kUploadClient[] = {
|
||||||
|
"FTP",
|
||||||
|
"SFTP",
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class CodyCam : public BApplication {
|
class CodyCam : public BApplication {
|
||||||
public:
|
public:
|
||||||
CodyCam();
|
CodyCam();
|
||||||
@@ -135,6 +143,8 @@ class VideoWindow : public BWindow {
|
|||||||
BMenuField* fCaptureRateSelector;
|
BMenuField* fCaptureRateSelector;
|
||||||
BMenu* fImageFormatMenu;
|
BMenu* fImageFormatMenu;
|
||||||
BMenuField* fImageFormatSelector;
|
BMenuField* fImageFormatSelector;
|
||||||
|
BMenu* fUploadClientMenu;
|
||||||
|
BMenuField* fUploadClientSelector;
|
||||||
BBox* fFtpSetupBox;
|
BBox* fFtpSetupBox;
|
||||||
BTextControl* fServerName;
|
BTextControl* fServerName;
|
||||||
BTextControl* fLoginId;
|
BTextControl* fLoginId;
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
|||||||
Application CodyCam :
|
Application CodyCam :
|
||||||
CodyCam.cpp
|
CodyCam.cpp
|
||||||
FileUploadClient.cpp
|
FileUploadClient.cpp
|
||||||
|
SpawningUploadClient.cpp
|
||||||
FtpClient.cpp
|
FtpClient.cpp
|
||||||
|
SftpClient.cpp
|
||||||
Settings.cpp
|
Settings.cpp
|
||||||
SettingsHandler.cpp
|
SettingsHandler.cpp
|
||||||
VideoConsumer.cpp
|
VideoConsumer.cpp
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
// VideoConsumer.cpp
|
// VideoConsumer.cpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "FileUploadClient.h"
|
||||||
#include "FtpClient.h"
|
#include "FtpClient.h"
|
||||||
|
#include "SftpClient.h"
|
||||||
#include "VideoConsumer.h"
|
#include "VideoConsumer.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -53,6 +55,7 @@ VideoConsumer::VideoConsumer(const char* name, BView* view, BStringView* statusL
|
|||||||
fRate(1000000),
|
fRate(1000000),
|
||||||
fImageFormat(0),
|
fImageFormat(0),
|
||||||
fTranslator(0),
|
fTranslator(0),
|
||||||
|
fUploadClient(0),
|
||||||
fPassiveFtp(true)
|
fPassiveFtp(true)
|
||||||
{
|
{
|
||||||
FUNCTION("VideoConsumer::VideoConsumer\n");
|
FUNCTION("VideoConsumer::VideoConsumer\n");
|
||||||
@@ -205,6 +208,7 @@ VideoConsumer::HandleMessage(int32 message, const void* data, size_t size)
|
|||||||
fImageFormat = info->imageFormat;
|
fImageFormat = info->imageFormat;
|
||||||
fTranslator = info->translator;
|
fTranslator = info->translator;
|
||||||
fPassiveFtp = info->passiveFtp;
|
fPassiveFtp = info->passiveFtp;
|
||||||
|
fUploadClient = info->uploadClient;
|
||||||
strcpy(fFileNameText, info->fileNameText);
|
strcpy(fFileNameText, info->fileNameText);
|
||||||
strcpy(fServerText, info->serverText);
|
strcpy(fServerText, info->serverText);
|
||||||
strcpy(fLoginText, info->loginText);
|
strcpy(fLoginText, info->loginText);
|
||||||
@@ -230,7 +234,7 @@ VideoConsumer::HandleMessage(int32 message, const void* data, size_t size)
|
|||||||
void
|
void
|
||||||
VideoConsumer::BufferReceived(BBuffer* buffer)
|
VideoConsumer::BufferReceived(BBuffer* buffer)
|
||||||
{
|
{
|
||||||
LOOP("VideoConsumer::Buffer #%ld received\n", buffer->ID());
|
LOOP("VideoConsumer::Buffer #%ld received, start_time %Ld\n", buffer->ID(), buffer->Header()->start_time);
|
||||||
|
|
||||||
if (RunState() == B_STOPPED) {
|
if (RunState() == B_STOPPED) {
|
||||||
buffer->Recycle();
|
buffer->Recycle();
|
||||||
@@ -673,25 +677,37 @@ VideoConsumer::LocalSave(char* filename, BBitmap* bitmap)
|
|||||||
status_t
|
status_t
|
||||||
VideoConsumer::FtpSave(char* filename)
|
VideoConsumer::FtpSave(char* filename)
|
||||||
{
|
{
|
||||||
FtpClient ftp;
|
FileUploadClient *ftp;
|
||||||
|
|
||||||
|
//XXX: make that cleaner
|
||||||
|
switch (fUploadClient) {
|
||||||
|
case 0:
|
||||||
|
ftp = new FtpClient;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ftp = new SftpClient;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
ftp.SetPassive(fPassiveFtp);
|
ftp->SetPassive(fPassiveFtp);
|
||||||
// ftp the local file to our web site
|
// ftp the local file to our web site
|
||||||
|
|
||||||
UpdateFtpStatus("Logging in ...");
|
UpdateFtpStatus("Logging in ...");
|
||||||
if (ftp.Connect((string)fServerText, (string)fLoginText, (string)fPasswordText)) {
|
if (ftp->Connect((string)fServerText, (string)fLoginText, (string)fPasswordText)) {
|
||||||
// connect to server
|
// connect to server
|
||||||
UpdateFtpStatus("Connected ...");
|
UpdateFtpStatus("Connected ...");
|
||||||
|
|
||||||
if (ftp.ChangeDir((string)fDirectoryText)) {
|
if (ftp->ChangeDir((string)fDirectoryText)) {
|
||||||
// cd to the desired directory
|
// cd to the desired directory
|
||||||
UpdateFtpStatus("Transmitting ...");
|
UpdateFtpStatus("Transmitting ...");
|
||||||
|
|
||||||
if (ftp.PutFile((string)filename, (string)"temp")) {
|
if (ftp->PutFile((string)filename, (string)"temp")) {
|
||||||
// send the file to the server
|
// send the file to the server
|
||||||
UpdateFtpStatus("Renaming ...");
|
UpdateFtpStatus("Renaming ...");
|
||||||
|
|
||||||
if (ftp.MoveFile((string)"temp", (string)filename)) {
|
if (ftp->MoveFile((string)"temp", (string)filename)) {
|
||||||
// change to the desired name
|
// change to the desired name
|
||||||
uint32 time = real_time_clock();
|
uint32 time = real_time_clock();
|
||||||
char s[80];
|
char s[80];
|
||||||
@@ -699,6 +715,7 @@ VideoConsumer::FtpSave(char* filename)
|
|||||||
strcat(s, ctime((const long*)&time));
|
strcat(s, ctime((const long*)&time));
|
||||||
s[strlen(s) - 1] = 0;
|
s[strlen(s) - 1] = 0;
|
||||||
UpdateFtpStatus(s);
|
UpdateFtpStatus(s);
|
||||||
|
delete ftp;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -713,6 +730,7 @@ VideoConsumer::FtpSave(char* filename)
|
|||||||
else
|
else
|
||||||
UpdateFtpStatus("Server login failed");
|
UpdateFtpStatus("Server login failed");
|
||||||
|
|
||||||
|
delete ftp;
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ typedef struct {
|
|||||||
bigtime_t rate;
|
bigtime_t rate;
|
||||||
uint32 imageFormat;
|
uint32 imageFormat;
|
||||||
int32 translator;
|
int32 translator;
|
||||||
|
int32 uploadClient;
|
||||||
bool passiveFtp;
|
bool passiveFtp;
|
||||||
char fileNameText[64];
|
char fileNameText[64];
|
||||||
char serverText[64];
|
char serverText[64];
|
||||||
@@ -137,6 +138,7 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer {
|
|||||||
bigtime_t fRate;
|
bigtime_t fRate;
|
||||||
uint32 fImageFormat;
|
uint32 fImageFormat;
|
||||||
int32 fTranslator;
|
int32 fTranslator;
|
||||||
|
int32 fUploadClient;
|
||||||
bool fPassiveFtp;
|
bool fPassiveFtp;
|
||||||
char fFileNameText[64];
|
char fFileNameText[64];
|
||||||
char fServerText[64];
|
char fServerText[64];
|
||||||
|
|||||||
Reference in New Issue
Block a user