diff --git a/src/apps/codycam/CodyCam.cpp b/src/apps/codycam/CodyCam.cpp index 4583d21fb7..2dc01eb27d 100644 --- a/src/apps/codycam/CodyCam.cpp +++ b/src/apps/codycam/CodyCam.cpp @@ -247,7 +247,7 @@ CodyCam::MessageReceived(BMessage *message) BRect(2 * WINDOW_OFFSET_X + WINDOW_SIZE_X, WINDOW_OFFSET_Y, 2 * WINDOW_OFFSET_X + WINDOW_SIZE_X + view->Bounds().right, WINDOW_OFFSET_Y + view->Bounds().bottom), view, node); - fMediaRoster->StartWatching(BMessenger(NULL, + fMediaRoster->StartWatching(BMessenger(NULL, fVideoControlWindow), node, B_MEDIA_WEB_CHANGED); fVideoControlWindow->Show(); } @@ -280,7 +280,7 @@ CodyCam::_SetUpNodes() /* find the media roster */ fMediaRoster = BMediaRoster::Roster(&status); if (status != B_OK) { - ErrorAlert(B_TRANSLATE("Cannot find the media roster"), status, + ErrorAlert(B_TRANSLATE("Cannot find the media roster"), status, fWindow); return status; } @@ -302,11 +302,11 @@ CodyCam::_SetUpNodes() } /* create the video consumer node */ - fVideoConsumer = new VideoConsumer("CodyCam", + fVideoConsumer = new VideoConsumer("CodyCam", ((VideoWindow*)fWindow)->VideoView(), ((VideoWindow*)fWindow)->StatusLine(), NULL, 0); if (!fVideoConsumer) { - ErrorAlert(B_TRANSLATE("Cannot create a video window"), B_ERROR, + ErrorAlert(B_TRANSLATE("Cannot create a video window"), B_ERROR, fWindow); return B_ERROR; } @@ -314,7 +314,7 @@ CodyCam::_SetUpNodes() /* register the node */ status = fMediaRoster->RegisterNode(fVideoConsumer); if (status != B_OK) { - ErrorAlert(B_TRANSLATE("Cannot register the video window"), status, + ErrorAlert(B_TRANSLATE("Cannot register the video window"), status, fWindow); return status; } @@ -322,18 +322,18 @@ CodyCam::_SetUpNodes() /* find free producer output */ int32 cnt = 0; - status = fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1, + status = fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1, &cnt, B_MEDIA_RAW_VIDEO); if (status != B_OK || cnt < 1) { status = B_RESOURCE_UNAVAILABLE; - ErrorAlert(B_TRANSLATE("Cannot find an available video stream"), + ErrorAlert(B_TRANSLATE("Cannot find an available video stream"), status, fWindow); return status; } /* find free consumer input */ cnt = 0; - status = fMediaRoster->GetFreeInputsFor(fVideoConsumer->Node(), + status = fMediaRoster->GetFreeInputsFor(fVideoConsumer->Node(), &fConsumerIn, 1, &cnt, B_MEDIA_RAW_VIDEO); if (status != B_OK || cnt < 1) { status = B_RESOURCE_UNAVAILABLE; @@ -350,7 +350,7 @@ CodyCam::_SetUpNodes() format.u.raw_video = vid_format; /* connect producer to consumer */ - status = fMediaRoster->Connect(fProducerOut.source, + status = fMediaRoster->Connect(fProducerOut.source, fConsumerIn.destination, &format, &fProducerOut, &fConsumerIn); if (status != B_OK) { ErrorAlert(B_TRANSLATE("Cannot connect the video source to the video " @@ -360,7 +360,7 @@ CodyCam::_SetUpNodes() /* set time sources */ - status = fMediaRoster->SetTimeSourceFor(fProducerNode.node, + status = fMediaRoster->SetTimeSourceFor(fProducerNode.node, fTimeSourceNode.node); if (status != B_OK) { ErrorAlert(B_TRANSLATE("Cannot set the time source for the video " @@ -368,7 +368,7 @@ CodyCam::_SetUpNodes() return status; } - status = fMediaRoster->SetTimeSourceFor(fVideoConsumer->ID(), + status = fMediaRoster->SetTimeSourceFor(fVideoConsumer->ID(), fTimeSourceNode.node); if (status != B_OK) { ErrorAlert(B_TRANSLATE("Cannot set the time source for the video " @@ -413,7 +413,7 @@ CodyCam::_SetUpNodes() } } - bigtime_t perf = timeSource->PerformanceTimeFor(real + latency + bigtime_t perf = timeSource->PerformanceTimeFor(real + latency + initLatency); timeSource->Release(); @@ -490,19 +490,19 @@ VideoWindow::VideoWindow(BRect frame, const char* title, window_type type, BMenuItem* menuItem; BMenu* menu = new BMenu(B_TRANSLATE("File")); - menuItem = new BMenuItem(B_TRANSLATE("Video settings"), + menuItem = new BMenuItem(B_TRANSLATE("Video settings"), new BMessage(msg_video), 'P'); menuItem->SetTarget(be_app); menu->AddItem(menuItem); menu->AddSeparatorItem(); - menuItem = new BMenuItem(B_TRANSLATE("Start video"), + menuItem = new BMenuItem(B_TRANSLATE("Start video"), new BMessage(msg_start), 'A'); menuItem->SetTarget(be_app); menu->AddItem(menuItem); - menuItem = new BMenuItem(B_TRANSLATE("Stop video"), + menuItem = new BMenuItem(B_TRANSLATE("Stop video"), new BMessage(msg_stop), 'O'); menuItem->SetTarget(be_app); menu->AddItem(menuItem); @@ -516,7 +516,7 @@ VideoWindow::VideoWindow(BRect frame, const char* title, window_type type, menu->AddSeparatorItem(); - menuItem = new BMenuItem(B_TRANSLATE("Quit"), + menuItem = new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q'); menuItem->SetTarget(be_app); menu->AddItem(menuItem); @@ -812,7 +812,7 @@ VideoWindow::_SetUpSettings(const char* filename, const char* dirname) fLoginSetting = new StringValueSetting("Login", "loginID", B_TRANSLATE("login ID expected")); - fPasswordSetting = new StringValueSetting("Password", + fPasswordSetting = new StringValueSetting("Password", B_TRANSLATE("password"), B_TRANSLATE("password expected")); fDirectorySetting = new StringValueSetting("Directory", "web/images", @@ -832,7 +832,7 @@ VideoWindow::_SetUpSettings(const char* filename, const char* dirname) "unrecognized capture rate specified"); fUploadClientSetting = new EnumeratedStringValueSetting("UploadClient", - B_TRANSLATE("FTP"), &UploadClientAt, + B_TRANSLATE("FTP"), &UploadClientAt, B_TRANSLATE("upload client name expected"), B_TRANSLATE("unrecognized upload client specified")); @@ -883,10 +883,10 @@ VideoWindow::_QuitSettings() // #pragma mark - -ControlWindow::ControlWindow(const BRect& frame, BView* controls, +ControlWindow::ControlWindow(const BRect& frame, BView* controls, media_node node) : - BWindow(frame, B_TRANSLATE("Video settings"), B_TITLED_WINDOW, + BWindow(frame, B_TRANSLATE("Video settings"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) { fView = controls; diff --git a/src/apps/codycam/CodyCam.h b/src/apps/codycam/CodyCam.h index 96e9a77629..66749e11c5 100644 --- a/src/apps/codycam/CodyCam.h +++ b/src/apps/codycam/CodyCam.h @@ -36,14 +36,14 @@ enum { msg_directory = 'drct', msg_passiveftp = 'pasv', msg_pswrd_text = 'pstx', - + msg_start = 'strt', msg_stop = 'stop', msg_about = 'abut', msg_setup = 'setp', msg_video = 'vdeo', - + msg_control_win = 'ctlw' }; diff --git a/src/apps/codycam/FtpClient.cpp b/src/apps/codycam/FtpClient.cpp index cafd7aa794..431e6a9cae 100644 --- a/src/apps/codycam/FtpClient.cpp +++ b/src/apps/codycam/FtpClient.cpp @@ -35,7 +35,7 @@ FtpClient::ChangeDir(const string& dir) string cmd = "CWD ", replyString; cmd += dir; - + if (dir.length() == 0) cmd += '/'; @@ -56,9 +56,9 @@ FtpClient::ListDirContents(string& listing) string cmd, replyString; int code, codeType, numRead; char buf[513]; - + cmd = "TYPE A"; - + if (_SendRequest(cmd)) _GetReply(replyString, code, codeType); @@ -100,7 +100,7 @@ FtpClient::PrintWorkingDir(string& dir) int code, codeType; string cmd = "PWD", replyString; long i; - + if (_SendRequest(cmd) == true) { if (_GetReply(replyString, code, codeType) == true) { if (codeType == 2) { @@ -125,10 +125,10 @@ FtpClient::Connect(const string& server, const string& login, const string& pass int code, codeType; string cmd, replyString; BNetAddress addr; - + delete fControl; delete fData; - + fControl = new BNetEndpoint; if (fControl->InitCheck() != B_NO_ERROR) @@ -137,7 +137,7 @@ FtpClient::Connect(const string& server, const string& login, const string& pass addr.SetTo(server.c_str(), "tcp", "ftp"); if (fControl->Connect(addr) == B_NO_ERROR) { // read the welcome message, do the login - + if (_GetReply(replyString, code, codeType)) { if (code != 421 && codeType != 5) { cmd = "USER "; @@ -146,8 +146,8 @@ FtpClient::Connect(const string& server, const string& login, const string& pass if (_GetReply(replyString, code, codeType)) { switch (code) { - case 230: - case 202: + case 230: + case 202: rc = true; break; @@ -163,12 +163,12 @@ FtpClient::Connect(const string& server, const string& login, const string& pass default: break; - + } } } } - } + } if (rc == true) _SetState(ftp_connected); @@ -189,7 +189,7 @@ FtpClient::PutFile(const string& local, const string& remote, ftp_mode mode) int code, codeType, rlen, slen, i; BFile infile(local.c_str(), B_READ_ONLY); char buf[8192], sbuf[16384], *stmp; - + if (infile.InitCheck() != B_NO_ERROR) return false; @@ -197,7 +197,7 @@ FtpClient::PutFile(const string& local, const string& remote, ftp_mode mode) cmd = "TYPE I"; else cmd = "TYPE A"; - + if (_SendRequest(cmd)) _GetReply(replyString, code, codeType); @@ -237,7 +237,7 @@ FtpClient::PutFile(const string& local, const string& remote, ftp_mode mode) throw "bail"; } } - + rc = true; } } @@ -247,7 +247,7 @@ FtpClient::PutFile(const string& local, const string& remote, ftp_mode mode) } catch(const char* errorString) - { + { } delete fData; @@ -257,7 +257,7 @@ FtpClient::PutFile(const string& local, const string& remote, ftp_mode mode) _GetReply(replyString, code, codeType); rc = codeType <= 2; } - + return rc; } @@ -286,7 +286,7 @@ FtpClient::GetFile(const string& remote, const string& local, ftp_mode mode) if (_OpenDataConnection()) { cmd = "RETR "; cmd += remote; - + if (_SendRequest(cmd)) { if (_GetReply(replyString, code, codeType)) { if (codeType <= 2) { @@ -297,7 +297,7 @@ FtpClient::GetFile(const string& remote, const string& local, ftp_mode mode) memset(buf, 0, sizeof(buf)); memset(sbuf, 0, sizeof(sbuf)); rlen = fData->Receive(buf, sizeof(buf)); - + if (rlen > 0) { slen = rlen; @@ -317,7 +317,7 @@ FtpClient::GetFile(const string& remote, const string& local, ftp_mode mode) if (slen > 0) { if (outfile.Write(stmp, slen) < 0) - writeError = true; + writeError = true; } } } @@ -329,8 +329,8 @@ FtpClient::GetFile(const string& remote, const string& local, ftp_mode mode) delete fData; fData = 0; - - if (rc) { + + if (rc) { _GetReply(replyString, code, codeType); rc = (codeType <= 2 && writeError == false); } @@ -378,7 +378,7 @@ FtpClient::Chmod(const string& path, const string& mod) cmd += mod; cmd += " "; cmd += path; - + if (path.length() == 0) cmd += '/'; printf(B_TRANSLATE("cmd: '%s'\n"), cmd.c_str()); @@ -429,7 +429,7 @@ FtpClient::_SendRequest(const string& cmd) { bool rc = false; string ccmd = cmd; - + if (fControl != 0) { if (cmd.find("PASS") != string::npos) printf(B_TRANSLATE("PASS (real password sent)\n")); @@ -440,7 +440,7 @@ FtpClient::_SendRequest(const string& cmd) if (fControl->Send(ccmd.c_str(), ccmd.length()) >= 0) rc = true; } - + return rc; } @@ -453,7 +453,7 @@ FtpClient::_GetReplyLine(string& line) bool done = false; line = ""; // Thanks to Stephen van Egmond for catching a bug here - + if (fControl != 0) { rc = true; while (done == false && fControl->Receive(&c, 1) > 0) { @@ -482,12 +482,12 @@ FtpClient::_GetReplyLine(string& line) treply[2] = c; fControl->Send(treply, 3); break; - + case EOF: case xEOF: done = true; break; - + default: line += c; break; @@ -498,9 +498,9 @@ FtpClient::_GetReplyLine(string& line) line += c; } } - } + } } - + return rc; } @@ -510,11 +510,11 @@ FtpClient::_GetReply(string& outString, int& outCode, int& codeType) { bool rc = false; string line, tempString; - + // // comment from the ncftp source: // - + /* RFC 959 states that a reply may span multiple lines. A single * line message would have the 3-digit code then the msg. * A multi-line message would have the code and the first @@ -534,10 +534,10 @@ FtpClient::_GetReply(string& outString, int& outCode, int& codeType) printf(outString.c_str()); tempString = line.substr(0, 3); outCode = atoi(tempString.c_str()); - + if (line[3] == '-') { while ((rc = _GetReplyLine(line)) == true) { - outString += line; + outString += line; outString += '\n'; printf(outString.c_str()); // we're done with nnn when we get to a "nnn blahblahblah" @@ -546,20 +546,20 @@ FtpClient::_GetReply(string& outString, int& outCode, int& codeType) } } } - + if (!rc && outCode != 421) { outString += B_TRANSLATE("Remote host has closed the connection.\n"); outCode = 421; } if (outCode == 421) { - delete fControl; + delete fControl; fControl = 0; _ClearState(ftp_connected); } codeType = outCode / 100; - + return rc; } @@ -573,12 +573,12 @@ FtpClient::_OpenDataConnection() int i, code, codeType; bool rc = false; struct sockaddr_in sa; - + delete fData; fData = 0; - + fData = new BNetEndpoint; - + if (_TestState(ftp_passive)) { // Here we send a "pasv" command and connect to the remote server // on the port it sends back to us @@ -597,7 +597,7 @@ FtpClient::_OpenDataConnection() replyString = replyString.substr(i, replyString.find(')') - i); if (sscanf(replyString.c_str(), "%d,%d,%d,%d,%d,%d", - &paddr[0], &paddr[1], &paddr[2], &paddr[3], + &paddr[0], &paddr[1], &paddr[2], &paddr[3], &paddr[4], &paddr[5]) != 6) { // cannot do passive. Do a little harmless rercursion here _ClearState(ftp_passive); @@ -649,7 +649,7 @@ FtpClient::_OpenDataConnection() rc = true; } } - + return rc; } @@ -660,19 +660,19 @@ FtpClient::_AcceptDataConnection() BNetEndpoint* endPoint; bool rc = false; - if (_TestState(ftp_passive) == false) { + if (_TestState(ftp_passive) == false) { if (fData != 0) { endPoint = fData->Accept(); if (endPoint != 0) { delete fData; fData = endPoint; rc = true; - } + } } - + } else rc = true; - return rc; + return rc; } diff --git a/src/apps/codycam/FtpClient.h b/src/apps/codycam/FtpClient.h index 305d9f522a..0536d5e5f0 100644 --- a/src/apps/codycam/FtpClient.h +++ b/src/apps/codycam/FtpClient.h @@ -15,12 +15,12 @@ using std::string; /* * Definitions for the TELNET protocol. Snarfed from the BSD source. */ -#define IAC 255 -#define DONT 254 -#define DO 253 -#define WONT 252 -#define WILL 251 -#define xEOF 236 +#define IAC 255 +#define DONT 254 +#define DO 253 +#define WONT 252 +#define WILL 251 +#define xEOF 236 class FtpClient : public FileUploadClient { @@ -44,7 +44,7 @@ class FtpClient : public FileUploadClient { bool Chmod(const string& path, const string& mod); void SetPassive(bool on); - + protected: enum { ftp_complete = 1UL, diff --git a/src/apps/codycam/Settings.cpp b/src/apps/codycam/Settings.cpp index 34945b830b..f34b377d41 100644 --- a/src/apps/codycam/Settings.cpp +++ b/src/apps/codycam/Settings.cpp @@ -35,13 +35,13 @@ StringValueSetting::~StringValueSetting() } -void +void StringValueSetting::ValueChanged(const char* newValue) { if (newValue == fValue) // guard against self assingment return; - + free(fValue); fValue = strdup(newValue); } @@ -54,7 +54,7 @@ StringValueSetting::Value() const } -void +void StringValueSetting::SaveSettingValue(Settings* settings) { printf("-----StringValueSetting::SaveSettingValue %s %s\n", Name(), fValue); @@ -62,7 +62,7 @@ StringValueSetting::SaveSettingValue(Settings* settings) } -bool +bool StringValueSetting::NeedsSaving() const { // needs saving if different than default @@ -73,10 +73,10 @@ StringValueSetting::NeedsSaving() const const char* StringValueSetting::Handle(const char *const *argv) { - if (!*++argv) + if (!*++argv) return fValueExpectedErrorString; - - ValueChanged(*argv); + + ValueChanged(*argv); return 0; } @@ -96,7 +96,7 @@ EnumeratedStringValueSetting::EnumeratedStringValueSetting(const char* name, } -void +void EnumeratedStringValueSetting::ValueChanged(const char* newValue) { #if DEBUG @@ -110,14 +110,14 @@ EnumeratedStringValueSetting::ValueChanged(const char* newValue) const char* EnumeratedStringValueSetting::Handle(const char *const *argv) { - if (!*++argv) + if (!*++argv) return fValueExpectedErrorString; printf("---EnumeratedStringValueSetting::Handle %s %s\n", *(argv-1), *argv); if (!_ValidateString(*argv)) return fWrongValueErrorString; - - ValueChanged(*argv); + + ValueChanged(*argv); return 0; } @@ -158,7 +158,7 @@ ScalarValueSetting::~ScalarValueSetting() } -void +void ScalarValueSetting::ValueChanged(int32 newValue) { ASSERT(newValue > fMin); @@ -174,7 +174,7 @@ ScalarValueSetting::Value() const } -void +void ScalarValueSetting::GetValueAsString(char* buffer) const { sprintf(buffer, "%ld", fValue); @@ -184,26 +184,26 @@ ScalarValueSetting::GetValueAsString(char* buffer) const const char* ScalarValueSetting::Handle(const char *const *argv) { - if (!*++argv) + if (!*++argv) return fValueExpectedErrorString; int32 newValue = atoi(*argv); if (newValue < fMin || newValue > fMax) return fWrongValueErrorString; - fValue = newValue; + fValue = newValue; return 0; } -void +void ScalarValueSetting::SaveSettingValue(Settings* settings) { settings->Write("%d", fValue); } -bool +bool ScalarValueSetting::NeedsSaving() const { return fValue != fDefaultValue; @@ -224,7 +224,7 @@ BooleanValueSetting::~BooleanValueSetting() } -bool +bool BooleanValueSetting::Value() const { return fValue; @@ -252,7 +252,7 @@ BooleanValueSetting::Handle(const char *const *argv) } -void +void BooleanValueSetting::SaveSettingValue(Settings* settings) { settings->Write(fValue ? "on" : "off"); diff --git a/src/apps/codycam/Settings.h b/src/apps/codycam/Settings.h index 6ab2b47c28..7bce95515a 100644 --- a/src/apps/codycam/Settings.h +++ b/src/apps/codycam/Settings.h @@ -10,7 +10,7 @@ class StringValueSetting : public SettingsArgvDispatcher { // simple string setting public: StringValueSetting(const char* name, - const char* defaultValue, + const char* defaultValue, const char* valueExpectedErrorString, const char* wrongValueErrorString = ""); @@ -18,7 +18,7 @@ public: void ValueChanged(const char* newValue); const char* Value() const; - virtual const char* Handle(const char *const *argv); + virtual const char* Handle(const char *const *argv); protected: virtual void SaveSettingValue(Settings*); @@ -46,7 +46,7 @@ public: const char* wrongValueErrorString); void ValueChanged(const char* newValue); - virtual const char* Handle(const char *const *argv); + virtual const char* Handle(const char *const *argv); private: bool _ValidateString(const char* string); @@ -67,7 +67,7 @@ public: void ValueChanged(int32 newValue); int32 Value() const; void GetValueAsString(char*) const; - virtual const char* Handle(const char *const *argv); + virtual const char* Handle(const char *const *argv); protected: virtual void SaveSettingValue(Settings*); @@ -89,7 +89,7 @@ public: virtual ~BooleanValueSetting(); bool Value() const; - virtual const char* Handle(const char *const *argv); + virtual const char* Handle(const char *const *argv); protected: virtual void SaveSettingValue(Settings *); diff --git a/src/apps/codycam/SettingsHandler.cpp b/src/apps/codycam/SettingsHandler.cpp index b40a66deac..6ed6d9de19 100644 --- a/src/apps/codycam/SettingsHandler.cpp +++ b/src/apps/codycam/SettingsHandler.cpp @@ -82,18 +82,18 @@ ArgvParser::~ArgvParser() } -void +void ArgvParser::MakeArgvEmpty() { // done with current argv, free it up for (int32 index = 0; index < fArgc; index++) delete fCurrentArgv[index]; - + fArgc = 0; } -status_t +status_t ArgvParser::SendArgv(ArgvHandler argvHandlerFunc, void* passThru) { if (fArgc) { @@ -111,7 +111,7 @@ ArgvParser::SendArgv(ArgvHandler argvHandlerFunc, void* passThru) } -void +void ArgvParser::NextArgv() { if (fSawBackslash) { @@ -120,7 +120,7 @@ ArgvParser::NextArgv() } fCurrentArgs[++fCurrentArgsPos] = '\0'; // terminate current arg pos - + // copy it as a string to the current argv slot fCurrentArgv[fArgc] = new char [strlen(fCurrentArgs) + 1]; strcpy(fCurrentArgv[fArgc], fCurrentArgs); @@ -129,7 +129,7 @@ ArgvParser::NextArgv() } -void +void ArgvParser::NextArgvIfNotEmpty() { if (!fSawBackslash && fCurrentArgsPos < 0) @@ -139,7 +139,7 @@ ArgvParser::NextArgvIfNotEmpty() } -char +char ArgvParser::GetCh() { if (fPos < 0 || fBuffer[fPos] == 0) { @@ -153,8 +153,8 @@ ArgvParser::GetCh() } -status_t -ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc, +status_t +ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc, void* passThru) { ArgvParser parser(name); @@ -162,7 +162,7 @@ ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc, } -status_t +status_t ArgvParser::EachArgvPrivate(const char* name, ArgvHandler argvHandlerFunc, void* passThru) { @@ -191,7 +191,7 @@ ArgvParser::EachArgvPrivate(const char* name, ArgvHandler argvHandlerFunc, result = B_ERROR; break; } - fLineNo++; + fLineNo++; if (fSawBackslash) { fSawBackslash = false; continue; @@ -202,7 +202,7 @@ ArgvParser::EachArgvPrivate(const char* name, ArgvHandler argvHandlerFunc, break; continue; } - + if (fEatComment) continue; @@ -260,7 +260,7 @@ SettingsArgvDispatcher::SettingsArgvDispatcher(const char* name) } -void +void SettingsArgvDispatcher::SaveSettings(Settings* settings, bool onlyIfNonDefault) { if (!onlyIfNonDefault || NeedsSaving()) { @@ -271,7 +271,7 @@ SettingsArgvDispatcher::SaveSettings(Settings* settings, bool onlyIfNonDefault) } -bool +bool SettingsArgvDispatcher::HandleRectValue(BRect &result, const char* const *argv, bool printError) { @@ -303,7 +303,7 @@ SettingsArgvDispatcher::HandleRectValue(BRect &result, const char* const *argv, } -void +void SettingsArgvDispatcher::WriteRectValue(Settings* setting, BRect rect) { setting->Write("%d %d %d %d", (int32)rect.left, (int32)rect.top, @@ -340,7 +340,7 @@ Settings::~Settings() { for (int32 index = 0; index < fCount; index++) delete fList[index]; - + free(fList); } @@ -410,7 +410,7 @@ Settings::TryReadingSettings() } -void +void Settings::SaveSettings(bool onlyIfNonDefault) { ASSERT(SettingsHandler()); @@ -418,13 +418,13 @@ Settings::SaveSettings(bool onlyIfNonDefault) } -void +void Settings::_MakeSettingsDirectory(BDirectory *resultingSettingsDir) { BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) return; - + // make sure there is a directory path.Append(fSettingsDir); mkdir(path.Path(), 0777); @@ -432,7 +432,7 @@ Settings::_MakeSettingsDirectory(BDirectory *resultingSettingsDir) } -void +void Settings::_SaveCurrentSettings(bool onlyIfNonDefault) { BDirectory fSettingsDir; @@ -445,7 +445,7 @@ Settings::_SaveCurrentSettings(bool onlyIfNonDefault) // nuke old settings BEntry entry(&fSettingsDir, fFileName); entry.Remove(); - + BFile prefs(&entry, O_RDWR | O_CREAT); if (prefs.InitCheck() != B_OK) return; @@ -459,7 +459,7 @@ Settings::_SaveCurrentSettings(bool onlyIfNonDefault) } -void +void Settings::Write(const char* format, ...) { va_list args; @@ -470,7 +470,7 @@ Settings::Write(const char* format, ...) } -void +void Settings::VSWrite(const char* format, va_list arg) { char buffer[2048]; diff --git a/src/apps/codycam/SettingsHandler.h b/src/apps/codycam/SettingsHandler.h index b80d42d0bf..4e19dadb00 100644 --- a/src/apps/codycam/SettingsHandler.h +++ b/src/apps/codycam/SettingsHandler.h @@ -75,7 +75,7 @@ class SettingsArgvDispatcher { virtual ~SettingsArgvDispatcher() {}; void SaveSettings(Settings* settings, bool onlyIfNonDefault); - + const char* Name() const { return fName; @@ -85,7 +85,7 @@ class SettingsArgvDispatcher { // override this adding an argv parser that reads in the // values in argv format for this setting // return a pointer to an error message or null if parsed OK - + bool HandleRectValue(BRect&, const char* const *argv, bool printError = true); diff --git a/src/apps/codycam/SftpClient.cpp b/src/apps/codycam/SftpClient.cpp index fb82b3a617..387ff9a8e5 100644 --- a/src/apps/codycam/SftpClient.cpp +++ b/src/apps/codycam/SftpClient.cpp @@ -69,7 +69,7 @@ SftpClient::PrintWorkingDir(string& dir) bool -SftpClient::Connect(const string& server, const string& login, +SftpClient::Connect(const string& server, const string& login, const string& passwd) { bool rc = false; @@ -88,7 +88,7 @@ SftpClient::Connect(const string& server, const string& login, rc = SpawningUploadClient::Connect(server, login, passwd); BString reply; ssize_t len; - + if ((len = ReadReply(&reply)) < 0) { fprintf(stderr, _GetLongReadText(), len); return false; @@ -96,7 +96,7 @@ SftpClient::Connect(const string& server, const string& login, fprintf(stderr, _GetReplyText(), reply.String()); if (reply.FindFirst("Connecting to ") != 0) return false; - + if ((len = ReadReply(&reply)) < 0) { fprintf(stderr, _GetLongReadText(), len); return false; @@ -104,10 +104,10 @@ SftpClient::Connect(const string& server, const string& login, fprintf(stderr, _GetReplyText(), reply.String()); if (reply.FindFirst(/*[pP]*/"assword:") < 0) return false; - + write(OutputPipe(), passwd.c_str(), strlen(passwd.c_str())); write(OutputPipe(), "\n", 1); - + if ((len = ReadReply(&reply)) < 0) { fprintf(stderr, _GetLongReadText(), len); return false; @@ -115,7 +115,7 @@ SftpClient::Connect(const string& server, const string& login, fprintf(stderr, _GetReplyText(), reply.String()); if (reply != "\n") return false; - + if ((len = ReadReply(&reply)) < 0) { fprintf(stderr, _GetLongReadText(), len); return false; @@ -175,7 +175,7 @@ SftpClient::MoveFile(const string& oldPath, const string& newPath) { bool rc = false; int len; - + // sftpd can't rename to an existing file... BString cmd("rm"); cmd << " " << newPath.c_str() << "\n"; diff --git a/src/apps/codycam/SftpClient.h b/src/apps/codycam/SftpClient.h index 7e13c63607..84892f5ceb 100644 --- a/src/apps/codycam/SftpClient.h +++ b/src/apps/codycam/SftpClient.h @@ -44,7 +44,7 @@ public: bool Chmod(const string& path, const string& mod); void SetPassive(bool on); - + private: const char* _GetLongReadText() const; const char* _GetReadText() const; diff --git a/src/apps/codycam/SpawningUploadClient.cpp b/src/apps/codycam/SpawningUploadClient.cpp index 90bd1eb240..8651394c7c 100644 --- a/src/apps/codycam/SpawningUploadClient.cpp +++ b/src/apps/codycam/SpawningUploadClient.cpp @@ -111,7 +111,7 @@ SpawningUploadClient::getpty(char *pty, char *tty) static const char minor[] = "0123456789abcdef"; uint32 i, j; int32 fd = -1; - + for (i = 0; i < sizeof(major); i++) { for (j = 0; j < sizeof(minor); j++) @@ -125,7 +125,7 @@ SpawningUploadClient::getpty(char *pty, char *tty) } } } - + return fd; } diff --git a/src/apps/codycam/VideoConsumer.cpp b/src/apps/codycam/VideoConsumer.cpp index 5b5778b69c..da92599ddc 100644 --- a/src/apps/codycam/VideoConsumer.cpp +++ b/src/apps/codycam/VideoConsumer.cpp @@ -44,11 +44,11 @@ const media_raw_video_format vid_format = {29.97, 1, 0, 239, B_VIDEO_TOP_LEFT_RIGHT, 1, 1, {B_RGB16, 320, 240, 320 * 4, 0, 0}}; -VideoConsumer::VideoConsumer(const char* name, BView* view, +VideoConsumer::VideoConsumer(const char* name, BView* view, BStringView* statusLine, BMediaAddOn* addon, const uint32 internalId) - : BMediaNode(name), - BMediaEventLooper(), + : BMediaNode(name), + BMediaEventLooper(), BBufferConsumer(B_MEDIA_RAW_VIDEO), fStatusLine(statusLine), fInternalID(internalId), @@ -72,7 +72,7 @@ VideoConsumer::VideoConsumer(const char* name, BView* view, AddNodeKind(B_PHYSICAL_OUTPUT); SetEventLatency(0); fWindow = fView->Window(); - + for (uint32 j = 0; j < 3; j++) { fBitmap[j] = NULL; fBufferMap[j] = 0; @@ -91,7 +91,7 @@ VideoConsumer::VideoConsumer(const char* name, BView* view, VideoConsumer::~VideoConsumer() { FUNCTION("VideoConsumer::~VideoConsumer\n"); - + Quit(); if (fWindow) { @@ -110,12 +110,12 @@ VideoConsumer::~VideoConsumer() snooze(1000000); count++; } - - if (count == 30) + + if (count == 30) kill_thread(fFtpThread); - + DeleteBuffers(); - + } /******************************** @@ -136,35 +136,35 @@ VideoConsumer::AddOn(long* cookie) const // This implementation is required to get around a bug in // the ppc compiler. -void +void VideoConsumer::Start(bigtime_t performanceTime) { BMediaEventLooper::Start(performanceTime); } -void +void VideoConsumer::Stop(bigtime_t performanceTime, bool immediate) { BMediaEventLooper::Stop(performanceTime, immediate); } -void +void VideoConsumer::Seek(bigtime_t mediaTime, bigtime_t performanceTime) { BMediaEventLooper::Seek(mediaTime, performanceTime); } -void +void VideoConsumer::TimeWarp(bigtime_t atRealTime, bigtime_t toPerformanceTime) { BMediaEventLooper::TimeWarp(atRealTime, toPerformanceTime); } -status_t +status_t VideoConsumer::DeleteHook(BMediaNode* node) { return BMediaEventLooper::DeleteHook(node); @@ -235,7 +235,7 @@ VideoConsumer::HandleMessage(int32 message, const void* data, size_t size) } break; } - + return status; } @@ -262,7 +262,7 @@ VideoConsumer::ProducerDataStatus(const media_destination& forWhom, int32 status { FUNCTION("VideoConsumer::ProducerDataStatus\n"); - if (forWhom != fIn.destination) + if (forWhom != fIn.destination) return; } @@ -272,14 +272,14 @@ VideoConsumer::CreateBuffers(const media_format& withFormat) { FUNCTION("VideoConsumer::CreateBuffers\n"); - DeleteBuffers(); + DeleteBuffers(); // delete any old buffers status_t status = B_OK; // create a buffer group uint32 xSize = withFormat.u.raw_video.display.line_width; - uint32 ySize = withFormat.u.raw_video.display.line_count; + uint32 ySize = withFormat.u.raw_video.display.line_count; color_space colorspace = withFormat.u.raw_video.display.format; PROGRESS("VideoConsumer::CreateBuffers - Colorspace = %d\n", colorspace); @@ -293,7 +293,7 @@ VideoConsumer::CreateBuffers(const media_format& withFormat) for (uint32 j = 0; j < 3; j++) { fBitmap[j] = new BBitmap(BRect(0, 0, (xSize - 1), (ySize - 1)), colorspace, false, true); - if (fBitmap[j]->IsValid()) { + if (fBitmap[j]->IsValid()) { buffer_clone_info info; if ((info.area = area_for(fBitmap[j]->Bits())) == B_ERROR) ERROR("VideoConsumer::CreateBuffers - ERROR IN AREA_FOR\n"); @@ -319,7 +319,7 @@ VideoConsumer::CreateBuffers(const media_format& withFormat) for (int j = 0; j < 3; j++) buffList[j] = 0; - if ((status = fBuffers->GetBufferList(3, buffList)) == B_OK) + if ((status = fBuffers->GetBufferList(3, buffList)) == B_OK) for (int j = 0; j < 3; j++) if (buffList[j] != NULL) { fBufferMap[j] = (uint32)buffList[j]; @@ -362,7 +362,7 @@ VideoConsumer::Connected(const media_source& producer, const media_destination& const media_format& withFormat, media_input* outInput) { FUNCTION("VideoConsumer::Connected\n"); - + fIn.source = producer; fIn.format = withFormat; fIn.node = Node(); @@ -370,9 +370,9 @@ VideoConsumer::Connected(const media_source& producer, const media_destination& *outInput = fIn; uint32 userData = 0; - int32 changeTag = 1; + int32 changeTag = 1; if (CreateBuffers(withFormat) == B_OK) - BBufferConsumer::SetOutputBuffersFor(producer, fDestination, + BBufferConsumer::SetOutputBuffersFor(producer, fDestination, fBuffers, (void *)&userData, &changeTag, true); else { ERROR("VideoConsumer::Connected - COULDN'T CREATE BUFFERS\n"); @@ -405,15 +405,15 @@ status_t VideoConsumer::AcceptFormat(const media_destination& dest, media_format* format) { FUNCTION("VideoConsumer::AcceptFormat\n"); - + if (dest != fIn.destination) { ERROR("VideoConsumer::AcceptFormat - BAD DESTINATION\n"); - return B_MEDIA_BAD_DESTINATION; + return B_MEDIA_BAD_DESTINATION; } if (format->type == B_MEDIA_NO_TYPE) format->type = B_MEDIA_RAW_VIDEO; - + if (format->type != B_MEDIA_RAW_VIDEO) { ERROR("VideoConsumer::AcceptFormat - BAD FORMAT\n"); return B_MEDIA_BAD_FORMAT; @@ -423,7 +423,7 @@ VideoConsumer::AcceptFormat(const media_destination& dest, media_format* format) && format->u.raw_video.display.format != B_RGB16 && format->u.raw_video.display.format != B_RGB15 && format->u.raw_video.display.format != B_GRAY8 - && + && format->u.raw_video.display.format != media_raw_video_format::wildcard.display.format) { ERROR("AcceptFormat - not a format we know about!\n"); return B_MEDIA_BAD_FORMAT; @@ -433,7 +433,7 @@ VideoConsumer::AcceptFormat(const media_destination& dest, media_format* format) format->u.raw_video.display.format = B_RGB16; } - char formatString[256]; + char formatString[256]; string_for_format(*format, formatString, 256); FUNCTION("VideoConsumer::AcceptFormat: %s\n", formatString); @@ -474,10 +474,10 @@ VideoConsumer::GetLatencyFor(const media_destination& forWhom, bigtime_t* outLat media_node_id* out_timesource) { FUNCTION("VideoConsumer::GetLatencyFor\n"); - + if (forWhom != fIn.destination) return B_MEDIA_BAD_DESTINATION; - + *outLatency = fMyLatency; *out_timesource = TimeSource()->ID(); return B_OK; @@ -485,7 +485,7 @@ VideoConsumer::GetLatencyFor(const media_destination& forWhom, bigtime_t* outLat status_t -VideoConsumer::FormatChanged(const media_source& producer, const media_destination& consumer, +VideoConsumer::FormatChanged(const media_source& producer, const media_destination& consumer, int32 fromChangeCount, const media_format& format) { FUNCTION("VideoConsumer::FormatChanged\n"); @@ -507,7 +507,7 @@ VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bool realTimeEvent) { LOOP("VideoConsumer::HandleEvent\n"); - + BBuffer* buffer; switch (event->type) { @@ -552,14 +552,14 @@ VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness, fOurBuffers = false; index = 0; } - + if (fFtpComplete && fTimeToFtp) { PROGRESS("VidConsumer::HandleEvent - SPAWNING FTP THREAD\n"); fTimeToFtp = false; fFtpComplete = false; memcpy(fFtpBitmap->Bits(), buffer->Data(), fFtpBitmap->BitsLength()); fFtpThread = spawn_thread(FtpRun, "Video Window Ftp", B_NORMAL_PRIORITY, this); - resume_thread(fFtpThread); + resume_thread(fFtpThread); } if ((RunMode() == B_OFFLINE) @@ -578,7 +578,7 @@ VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness, int32 size = fBitmap[index]->BitsLength(); uint32* end = start + size / 4; for (uint32* p = start; p < end; p++) - *p = (*p >> 3) & 0x1f1f1f1f; + *p = (*p >> 3) & 0x1f1f1f1f; } fView->DrawBitmap(fBitmap[index], fView->Bounds()); @@ -597,7 +597,7 @@ VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness, default: ERROR("VideoConsumer::HandleEvent - BAD EVENT\n"); break; - } + } } @@ -605,7 +605,7 @@ status_t VideoConsumer::FtpRun(void* data) { FUNCTION("VideoConsumer::FtpRun\n"); - + ((VideoConsumer *)data)->FtpThread(); return 0; @@ -633,15 +633,15 @@ VideoConsumer::FtpThread() b->Lock(); v->DrawBitmap(fFtpBitmap, v->Frame()); v->Sync(); - b->Unlock(); + b->Unlock(); - if (LocalSave("small.jpg", b) == B_OK) + if (LocalSave("small.jpg", b) == B_OK) FtpSave("small.jpg"); - + delete b; #endif - - fFtpComplete = true; + + fFtpComplete = true; } @@ -684,7 +684,7 @@ VideoConsumer::LocalSave(char* filename, BBitmap* bitmap) } else { UpdateFtpStatus(B_TRANSLATE("Error creating output file")); return B_ERROR; - } + } } @@ -692,7 +692,7 @@ status_t VideoConsumer::FtpSave(char* filename) { FileUploadClient *ftp; - + //XXX: make that cleaner switch (fUploadClient) { case 0: @@ -704,7 +704,7 @@ VideoConsumer::FtpSave(char* filename) case 2: return B_OK; default: - fprintf(stderr, B_TRANSLATE("invalid upload client %ld\n"), + fprintf(stderr, B_TRANSLATE("invalid upload client %ld\n"), fUploadClient); return EINVAL; } @@ -713,7 +713,7 @@ VideoConsumer::FtpSave(char* filename) // ftp the local file to our web site UpdateFtpStatus(B_TRANSLATE("Logging in" B_UTF8_ELLIPSIS)); - if (ftp->Connect((string)fServerText, (string)fLoginText, + if (ftp->Connect((string)fServerText, (string)fLoginText, (string)fPasswordText)) { // connect to server UpdateFtpStatus(B_TRANSLATE("Connected" B_UTF8_ELLIPSIS)); @@ -760,8 +760,8 @@ VideoConsumer::FtpSave(char* filename) status_t -SetFileType(BFile* file, int32 translator, uint32 type) -{ +SetFileType(BFile* file, int32 translator, uint32 type) +{ translation_format* formats; int32 count; diff --git a/src/apps/codycam/VideoConsumer.h b/src/apps/codycam/VideoConsumer.h index ac5439491a..473bd4f069 100644 --- a/src/apps/codycam/VideoConsumer.h +++ b/src/apps/codycam/VideoConsumer.h @@ -25,7 +25,7 @@ typedef struct { char fileNameText[64]; char serverText[64]; char loginText[64]; - char passwordText[64]; + char passwordText[64]; char directoryText[64]; } ftp_msg_info; @@ -80,10 +80,10 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer { private: virtual void ProducerDataStatus(const media_destination &forWhom, int32 status, bigtime_t atMediaTime); - + virtual status_t GetLatencyFor(const media_destination& forWhom, bigtime_t* outLatency, media_node_id* outId); - + virtual status_t Connected(const media_source& producer, const media_destination& where, const media_format& withFormat, media_input* outInput); @@ -101,11 +101,11 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer { status_t CreateBuffers(const media_format& withFormat); void DeleteBuffers(); - + static status_t FtpRun(void* data); void FtpThread(); - + void UpdateFtpStatus(const char* status); status_t LocalSave(char* filename, BBitmap* bitmap); @@ -129,11 +129,11 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer { BBitmap* fBitmap[3]; bool fOurBuffers; BBufferGroup* fBuffers; - uint32 fBufferMap[3]; + uint32 fBufferMap[3]; BBitmap* fFtpBitmap; - volatile bool fTimeToFtp; - volatile bool fFtpComplete; + volatile bool fTimeToFtp; + volatile bool fFtpComplete; bigtime_t fRate; uint32 fImageFormat; @@ -143,7 +143,7 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer { char fFileNameText[64]; char fServerText[64]; char fLoginText[64]; - char fPasswordText[64]; + char fPasswordText[64]; char fDirectoryText[64]; }; diff --git a/src/apps/codycam/makefile b/src/apps/codycam/makefile index dd6a09278a..11f11b2a0e 100644 --- a/src/apps/codycam/makefile +++ b/src/apps/codycam/makefile @@ -20,7 +20,7 @@ TYPE= APP # to fill in generic makefile #%{ -# @src->@ +# @src->@ # specify the source files to use # full paths or paths relative to the makefile can be included @@ -41,7 +41,7 @@ SRCS= \ # full path or a relative path to the resource file can be used. RSRCS= codycam.rsrc -# @<-src@ +# @<-src@ #%} # end support for Pe and Eddie @@ -51,7 +51,7 @@ RSRCS= codycam.rsrc # - if your library follows the naming pattern of: # libXXX.so or libXXX.a you can simply specify XXX # library: libbe.so entry: be -# +# # - if your library does not follow the standard library # naming scheme you need to specify the path to the library # and it's name @@ -69,17 +69,17 @@ endif # be recursive, so include all of the paths where libraries can # be found. Directories where source files are found are # automatically included. -LIBPATHS= +LIBPATHS= # additional paths to look for system headers # thes use the form: #include
# source file directories are NOT auto-included here -SYSTEM_INCLUDE_PATHS = +SYSTEM_INCLUDE_PATHS = # additional paths to look for local headers # thes use the form: #include "header" # source file directories are automatically included -LOCAL_INCLUDE_PATHS = +LOCAL_INCLUDE_PATHS = # specify the level of optimization that you desire # NONE, SOME, FULL @@ -90,23 +90,23 @@ OPTIMIZE= FULL # to use. For example, setting DEFINES to "DEBUG=1" will cause the # compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" # would pass "-DDEBUG" on the compiler's command line. -DEFINES= +DEFINES= # specify special warning levels # if unspecified default warnings will be used # NONE = supress all warnings # ALL = enable all warnings -WARNINGS = +WARNINGS = # specify whether image symbols will be created # so that stack crawls in the debugger are meaningful # if TRUE symbols will be created -SYMBOLS = +SYMBOLS = # specify debug settings # if TRUE will allow application to be run from a source-level # debugger. Note that this will disable all optimzation. -DEBUGGER = +DEBUGGER = # specify additional compiler flags for all files COMPILER_FLAGS =