Ticket #5908: codycamLocalization.patch
File codycamLocalization.patch, 49.9 KB (added by , 14 years ago) |
---|
-
src/apps/codycam/SettingsHandler.cpp
5 5 #include <stdlib.h> 6 6 #include <string.h> 7 7 8 #include <Catalog.h> 8 9 #include <Debug.h> 9 10 #include <Directory.h> 10 11 #include <Entry.h> 11 12 #include <File.h> 12 13 #include <FindDirectory.h> 14 #include <Locale.h> 13 15 #include <Path.h> 14 16 #include <StopWatch.h> 15 17 18 #undef TR_CONTEXT 19 #define TR_CONTEXT "SettingsHandler" 16 20 17 21 #if 0 18 22 static int … … 56 60 { 57 61 fFile = fopen(fFileName, "r"); 58 62 if (!fFile) { 59 PRINT(( "Error opening %s\n", fFileName));63 PRINT((TR("Error opening %s\n"), fFileName)); 60 64 return; 61 65 } 62 66 fBuffer = new char [kBufferSize]; … … 95 99 fCurrentArgv[fArgc] = 0; 96 100 const char *result = (argvHandlerFunc)(fArgc, fCurrentArgv, passThru); 97 101 if (result) 98 printf( "File %s; Line %ld # %s", fFileName, fLineNo, result);102 printf(TR("File %s; Line %ld # %s"), fFileName, fLineNo, result); 99 103 MakeArgvEmpty(); 100 104 if (result) 101 105 return B_ERROR; … … 148 152 149 153 150 154 status_t 151 ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc, void* passThru) 155 ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc, 156 void* passThru) 152 157 { 153 158 ArgvParser parser(name); 154 159 return parser.EachArgvPrivate(name, argvHandlerFunc, passThru); … … 166 171 if (ch == EOF) { 167 172 // done with file 168 173 if (fInDoubleQuote || fInSingleQuote) { 169 printf("File %s # unterminated quote at end of file\n", name); 174 printf(TR("File %s # unterminated quote at end of file\n"), 175 name); 170 176 result = B_ERROR; 171 177 break; 172 178 } … … 178 184 // handle new line 179 185 fEatComment = false; 180 186 if (!fSawBackslash && (fInDoubleQuote || fInSingleQuote)) { 181 printf("File %s ; Line %ld # unterminated quote\n", name, fLineNo); 187 printf(TR("File %s ; Line %ld # unterminated quote\n"), name, 188 fLineNo); 182 189 result = B_ERROR; 183 190 break; 184 191 } … … 268 275 { 269 276 if (!*argv) { 270 277 if (printError) 271 printf( "rect left expected");278 printf(TR("rect left expected")); 272 279 return false; 273 280 } 274 281 result.left = atoi(*argv); 275 282 if (!*++argv) { 276 283 if (printError) 277 printf( "rect top expected");284 printf(TR("rect top expected")); 278 285 return false; 279 286 } 280 287 result.top = atoi(*argv); 281 288 if (!*++argv) { 282 289 if (printError) 283 printf( "rect right expected");290 printf(TR("rect right expected")); 284 291 return false; 285 292 } 286 293 result.right = atoi(*argv); 287 294 if (!*++argv) { 288 295 if (printError) 289 printf( "rect bottom expected");296 printf(TR("rect bottom expected")); 290 297 return false; 291 298 } 292 299 result.bottom = atoi(*argv); … … 350 357 351 358 SettingsArgvDispatcher* handler = settings->_Find(*argv); 352 359 if (!handler) 353 return "unknown command";360 return TR("unknown command"); 354 361 return handler->Handle(argv); 355 362 } 356 363 -
src/apps/codycam/Settings.cpp
1 1 #include "Settings.h" 2 2 3 #include <Catalog.h> 4 #include <Locale.h> 5 3 6 #include <stdio.h> 4 7 #include <stdlib.h> 5 8 #include <string.h> … … 7 10 #include <Debug.h> 8 11 9 12 13 #undef TR_CONTEXT 14 #define TR_CONTEXT "Settings" 15 10 16 Settings* settings = NULL; 11 17 12 18 … … 49 55 void 50 56 StringValueSetting::SaveSettingValue(Settings* settings) 51 57 { 52 printf("-------StringValueSetting::SaveSettingValue %s %s\n", Name(), fValue); 58 printf("-------StringValueSetting::SaveSettingValue %s %s\n", Name(), 59 fValue); 53 60 settings->Write("\"%s\"", fValue); 54 61 } 55 62 … … 80 87 const char* defaultValue, const char *const *values, 81 88 const char* valueExpectedErrorString, 82 89 const char* wrongValueErrorString) 83 : StringValueSetting(name, defaultValue, valueExpectedErrorString, wrongValueErrorString), 90 : StringValueSetting(name, defaultValue, valueExpectedErrorString, 91 wrongValueErrorString), 84 92 fValues(values) 85 93 { 86 94 } … … 230 238 BooleanValueSetting::Handle(const char *const *argv) 231 239 { 232 240 if (!*++argv) 233 return "on or off expected";241 return TR("on or off expected"); 234 242 235 243 if (strcmp(*argv, "on") == 0) 236 244 fValue = true; 237 245 else if (strcmp(*argv, "off") == 0) 238 246 fValue = false; 239 247 else 240 return "on or off expected";248 return TR("on or off expected"); 241 249 242 250 return 0; 243 251 } -
src/apps/codycam/SftpClient.cpp
3 3 4 4 #include "SftpClient.h" 5 5 6 6 7 SftpClient::SftpClient() 7 8 : SpawningUploadClient() 8 9 { … … 26 27 cmd << " " << dir.c_str() << "\n"; 27 28 SendCommand(cmd.String()); 28 29 if ((len = ReadReply(&reply)) < 0) { 29 fprintf(stderr, "read: %d\n", len);30 fprintf(stderr, GetReadText(), len); 30 31 return false; 31 32 } 32 fprintf(stderr, "reply: '%s'\n", reply.String());33 fprintf(stderr, GetReplyText(), reply.String()); 33 34 if (reply.FindFirst("sftp>") < 0) 34 35 return false; 35 36 rc = true; … … 46 47 BString reply; 47 48 do { 48 49 if ((len = ReadReply(&reply)) < 0) { 49 fprintf(stderr, "read: %d\n", len);50 fprintf(stderr, GetReadText(), len); 50 51 return false; 51 52 } 52 fprintf(stderr, "reply: '%s'\n", reply.String());53 fprintf(stderr, GetReplyText(), reply.String()); 53 54 printf("%s", reply.String()); 54 55 if (reply.FindFirst("sftp>") == 0) 55 56 return true; … … 69 70 70 71 71 72 bool 72 SftpClient::Connect(const string& server, const string& login, const string& passwd) 73 SftpClient::Connect(const string& server, const string& login, 74 const string& passwd) 73 75 { 74 76 bool rc = false; 75 77 BString cmd("sftp "); … … 82 84 cmd << "-oPort=" << port << " "; 83 85 cmd << login.c_str(); 84 86 cmd << "@" << host.String(); 85 printf( "COMMAND: '%s'\n", cmd.String());87 printf(TR("COMMAND: '%s'\n"), cmd.String()); 86 88 SetCommandLine(cmd.String()); 87 89 rc = SpawningUploadClient::Connect(server, login, passwd); 88 90 BString reply; 89 91 ssize_t len; 90 92 91 93 if ((len = ReadReply(&reply)) < 0) { 92 fprintf(stderr, "read: %ld\n", len);94 fprintf(stderr, GetLReadText(), len); 93 95 return false; 94 96 } 95 fprintf(stderr, "reply: '%s'\n", reply.String());97 fprintf(stderr, GetReplyText(), reply.String()); 96 98 if (reply.FindFirst("Connecting to ") != 0) 97 99 return false; 98 100 99 101 if ((len = ReadReply(&reply)) < 0) { 100 fprintf(stderr, "read: %ld\n", len);102 fprintf(stderr, GetLReadText(), len); 101 103 return false; 102 104 } 103 fprintf(stderr, "reply: '%s'\n", reply.String());105 fprintf(stderr, GetReplyText(), reply.String()); 104 106 if (reply.FindFirst(/*[pP]*/"assword:") < 0) 105 107 return false; 106 108 … … 108 110 write(OutputPipe(), "\n", 1); 109 111 110 112 if ((len = ReadReply(&reply)) < 0) { 111 fprintf(stderr, "read: %ld\n", len);113 fprintf(stderr, GetLReadText(), len); 112 114 return false; 113 115 } 114 fprintf(stderr, "reply: '%s'\n", reply.String());116 fprintf(stderr, GetReplyText(), reply.String()); 115 117 if (reply != "\n") 116 118 return false; 117 119 118 120 if ((len = ReadReply(&reply)) < 0) { 119 fprintf(stderr, "read: %ld\n", len);121 fprintf(stderr, GetLReadText(), len); 120 122 return false; 121 123 } 122 fprintf(stderr, "reply: '%s'\n", reply.String());124 fprintf(stderr, GetReplyText(), reply.String()); 123 125 if (reply.FindFirst("sftp>") < 0) 124 126 return false; 125 127 return rc; … … 138 140 BString reply; 139 141 140 142 if ((len = ReadReply(&reply)) < 0) { 141 fprintf(stderr, "read: %d\n", len);143 fprintf(stderr, GetReadText(), len); 142 144 return false; 143 145 } 144 fprintf(stderr, "reply: '%s'\n", reply.String());146 fprintf(stderr, GetReplyText(), reply.String()); 145 147 if (reply.FindFirst("Uploading") < 0) 146 148 return false; 147 149 148 150 if ((len = ReadReply(&reply)) < 0) { 149 fprintf(stderr, "read: %d\n", len);151 fprintf(stderr, GetReadText(), len); 150 152 return false; 151 153 } 152 fprintf(stderr, "reply: '%s'\n", reply.String());154 fprintf(stderr, GetReplyText(), reply.String()); 153 155 if (reply.FindFirst("sftp>") < 0) 154 156 return false; 155 157 … … 178 180 // sftpd can't rename to an existing file... 179 181 BString cmd("rm"); 180 182 cmd << " " << newPath.c_str() << "\n"; 181 fprintf(stderr, "CMD: '%s'\n", cmd.String());183 fprintf(stderr, TR("CMD: '%s'\n"), cmd.String()); 182 184 SendCommand(cmd.String()); 183 185 BString reply; 184 186 185 187 if ((len = ReadReply(&reply)) < 0) { 186 fprintf(stderr, "read: %d\n", len);188 fprintf(stderr, GetReadText(), len); 187 189 return false; 188 190 } 189 fprintf(stderr, "reply: '%s'\n", reply.String());191 fprintf(stderr, GetReplyText(), reply.String()); 190 192 // we don't care if it worked or not. 191 193 //if (reply.FindFirst("Removing") != 0 && reply.FindFirst("Couldn't") ) 192 194 // return false; 193 195 194 196 if ((len = ReadReply(&reply)) < 0) { 195 fprintf(stderr, "read: %d\n", len);197 fprintf(stderr, GetReadText(), len); 196 198 return false; 197 199 } 198 fprintf(stderr, "reply: '%s'\n", reply.String());200 fprintf(stderr, GetReplyText(), reply.String()); 199 201 if (reply.FindFirst("sftp>") < 0) 200 202 return false; 201 203 … … 203 205 cmd << " " << oldPath.c_str() << " " << newPath.c_str() << "\n"; 204 206 SendCommand(cmd.String()); 205 207 if ((len = ReadReply(&reply)) < 0) { 206 fprintf(stderr, "read: %d\n", len);208 fprintf(stderr, GetReadText(), len); 207 209 return false; 208 210 } 209 fprintf(stderr, "reply: '%s'\n", reply.String());211 fprintf(stderr, GetReplyText(), reply.String()); 210 212 if (reply.FindFirst("sftp>") < 0) 211 213 return false; 212 214 rc = true; … … 226 228 BString reply; 227 229 228 230 if ((len = ReadReply(&reply)) < 0) { 229 fprintf(stderr, "read: %d\n", len);231 fprintf(stderr, GetReadText(), len); 230 232 return false; 231 233 } 232 fprintf(stderr, "reply: '%s'\n", reply.String());234 fprintf(stderr, GetReplyText(), reply.String()); 233 235 if (reply.FindFirst("Changing") < 0) 234 236 return false; 235 237 236 238 if ((len = ReadReply(&reply)) < 0) { 237 fprintf(stderr, "read: %d\n", len);239 fprintf(stderr, GetReadText(), len); 238 240 return false; 239 241 } 240 fprintf(stderr, "reply: '%s'\n", reply.String());242 fprintf(stderr, GetReplyText(), reply.String()); 241 243 if (reply.FindFirst("sftp>") < 0) 242 244 return false; 243 245 -
src/apps/codycam/CodyCam.cpp
57 57 static void 58 58 ErrorAlert(const char* message, status_t err, BWindow *window = NULL) 59 59 { 60 BAlert *alert = new BAlert("", message, "OK");60 BAlert *alert = new BAlert("", message, TR("OK")); 61 61 if (window != NULL) 62 62 alert->CenterIn(window->Frame()); 63 63 alert->Go(); … … 127 127 fVideoConsumer(NULL), 128 128 fWindow(NULL), 129 129 fPort(0), 130 fVideoControlWindow(NULL) 130 fVideoControlWindow(NULL), 131 fAppCatalog(NULL) 131 132 { 132 133 chdir("/boot/home"); 134 be_locale->GetAppCatalog(&fAppCatalog); 133 135 } 134 136 135 137 … … 152 154 CodyCam::ReadyToRun() 153 155 { 154 156 fWindow = new VideoWindow(BRect(28, 28, 28, 28), 155 (const char*) "CodyCam", B_TITLED_WINDOW,157 (const char*) TR("CodyCam"), B_TITLED_WINDOW, 156 158 B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, &fPort); 157 159 158 160 _SetUpNodes(); … … 178 180 switch (message->what) { 179 181 case msg_start: 180 182 { 181 BTimeSource* timeSource = fMediaRoster->MakeTimeSourceFor(fTimeSourceNode); 183 BTimeSource* timeSource 184 = fMediaRoster->MakeTimeSourceFor(fTimeSourceNode); 182 185 bigtime_t real = BTimeSource::RealTime(); 183 186 bigtime_t perf = timeSource->PerformanceTimeFor(real) + 10000; 184 187 status_t status = fMediaRoster->StartNode(fProducerNode, perf); 185 188 if (status != B_OK) 186 ERROR( "error starting producer!");189 ERROR(TR("error starting producer!")); 187 190 timeSource->Release(); 188 191 break; 189 192 } … … 208 211 BRect(2 * WINDOW_OFFSET_X + WINDOW_SIZE_X, WINDOW_OFFSET_Y, 209 212 2 * WINDOW_OFFSET_X + WINDOW_SIZE_X + view->Bounds().right, 210 213 WINDOW_OFFSET_Y + view->Bounds().bottom), view, node); 211 fMediaRoster->StartWatching(BMessenger(NULL, fVideoControlWindow), node,212 B_MEDIA_WEB_CHANGED);214 fMediaRoster->StartWatching(BMessenger(NULL, 215 fVideoControlWindow), node, B_MEDIA_WEB_CHANGED); 213 216 fVideoControlWindow->Show(); 214 217 } 215 218 break; 216 219 } 217 220 218 221 case msg_about: 219 (new BAlert( "About CodyCam", "CodyCam\n\nThe Original BeOS webcam",220 " Close"))->Go();222 (new BAlert(TR("About CodyCam"), TR("CodyCam\n\nThe Original BeOS " 223 "webcam"), TR("Close")))->Go(); 221 224 break; 222 225 223 226 case msg_control_win: … … 241 244 /* find the media roster */ 242 245 fMediaRoster = BMediaRoster::Roster(&status); 243 246 if (status != B_OK) { 244 ErrorAlert( "Cannot find the media roster", status, fWindow);247 ErrorAlert(TR("Cannot find the media roster"), status, fWindow); 245 248 return status; 246 249 } 247 250 248 251 /* find the time source */ 249 252 status = fMediaRoster->GetTimeSource(&fTimeSourceNode); 250 253 if (status != B_OK) { 251 ErrorAlert( "Cannot get a time source", status, fWindow);254 ErrorAlert(TR("Cannot get a time source"), status, fWindow); 252 255 return status; 253 256 } 254 257 255 258 /* find a video producer node */ 256 INFO( "CodyCam acquiring VideoInput node\n");259 INFO(TR("CodyCam acquiring VideoInput node\n")); 257 260 status = fMediaRoster->GetVideoInput(&fProducerNode); 258 261 if (status != B_OK) { 259 ErrorAlert("Cannot find a video source. You need a webcam to use CodyCam.", status, fWindow); 262 ErrorAlert(TR("Cannot find a video source. You need a webcam to use " 263 "CodyCam."), status, fWindow); 260 264 return status; 261 265 } 262 266 263 267 /* create the video consumer node */ 264 fVideoConsumer = new VideoConsumer("CodyCam", ((VideoWindow*)fWindow)->VideoView(), 268 fVideoConsumer = new VideoConsumer(TR("CodyCam"), 269 ((VideoWindow*)fWindow)->VideoView(), 265 270 ((VideoWindow*)fWindow)->StatusLine(), NULL, 0); 266 271 if (!fVideoConsumer) { 267 ErrorAlert( "Cannot create a video window", B_ERROR, fWindow);272 ErrorAlert(TR("Cannot create a video window"), B_ERROR, fWindow); 268 273 return B_ERROR; 269 274 } 270 275 271 276 /* register the node */ 272 277 status = fMediaRoster->RegisterNode(fVideoConsumer); 273 278 if (status != B_OK) { 274 ErrorAlert( "Cannot register the video window", status, fWindow);279 ErrorAlert(TR("Cannot register the video window"), status, fWindow); 275 280 return status; 276 281 } 277 282 fPort = fVideoConsumer->ControlPort(); 278 283 279 284 /* find free producer output */ 280 285 int32 cnt = 0; 281 status = fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1, &cnt,282 B_MEDIA_RAW_VIDEO);286 status = fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1, 287 &cnt, B_MEDIA_RAW_VIDEO); 283 288 if (status != B_OK || cnt < 1) { 284 289 status = B_RESOURCE_UNAVAILABLE; 285 ErrorAlert("Cannot find an available video stream", status, fWindow); 290 ErrorAlert(TR("Cannot find an available video stream"), status, 291 fWindow); 286 292 return status; 287 293 } 288 294 289 295 /* find free consumer input */ 290 296 cnt = 0; 291 status = fMediaRoster->GetFreeInputsFor(fVideoConsumer->Node(), &fConsumerIn, 1,292 & cnt, B_MEDIA_RAW_VIDEO);297 status = fMediaRoster->GetFreeInputsFor(fVideoConsumer->Node(), 298 &fConsumerIn, 1, &cnt, B_MEDIA_RAW_VIDEO); 293 299 if (status != B_OK || cnt < 1) { 294 300 status = B_RESOURCE_UNAVAILABLE; 295 ErrorAlert("Can't find an available connection to the video window", status, fWindow); 301 ErrorAlert(TR("Can't find an available connection to the video window"), 302 status, fWindow); 296 303 return status; 297 304 } 298 305 … … 307 314 status = fMediaRoster->Connect(fProducerOut.source, fConsumerIn.destination, 308 315 &format, &fProducerOut, &fConsumerIn); 309 316 if (status != B_OK) { 310 ErrorAlert("Cannot connect the video source to the video window", status); 317 ErrorAlert(TR("Cannot connect the video source to the video window"), 318 status); 311 319 return status; 312 320 } 313 321 … … 315 323 /* set time sources */ 316 324 status = fMediaRoster->SetTimeSourceFor(fProducerNode.node, fTimeSourceNode.node); 317 325 if (status != B_OK) { 318 ErrorAlert("Cannot set the time source for the video source", status); 326 ErrorAlert(TR("Cannot set the time source for the video source"), 327 status); 319 328 return status; 320 329 } 321 330 322 331 status = fMediaRoster->SetTimeSourceFor(fVideoConsumer->ID(), fTimeSourceNode.node); 323 332 if (status != B_OK) { 324 ErrorAlert("Cannot set the time source for the video window", status); 333 ErrorAlert(TR("Cannot set the time source for the video window"), 334 status); 325 335 return status; 326 336 } 327 337 … … 334 344 bigtime_t initLatency = 0; 335 345 status = fMediaRoster->GetInitialLatencyFor(fProducerNode, &initLatency); 336 346 if (status < B_OK) { 337 ErrorAlert("Error getting initial latency for the capture node", status); 347 ErrorAlert(TR("Error getting initial latency for the capture node"), 348 status); 338 349 return status; 339 350 } 340 351 … … 350 361 status = fMediaRoster->StartTimeSource(fTimeSourceNode, real); 351 362 if (status != B_OK) { 352 363 timeSource->Release(); 353 ErrorAlert("Cannot start time source!", status); 364 ErrorAlert(TR("Cannot start time source!"), 365 status); 354 366 return status; 355 367 } 356 368 status = fMediaRoster->SeekTimeSource(fTimeSourceNode, 0, real); 357 369 if (status != B_OK) { 358 370 timeSource->Release(); 359 ErrorAlert( "Cannot seek time source!", status);371 ErrorAlert(TR("Cannot seek time source!"), status); 360 372 return status; 361 373 } 362 374 } … … 367 379 /* start the nodes */ 368 380 status = fMediaRoster->StartNode(fProducerNode, perf); 369 381 if (status != B_OK) { 370 ErrorAlert( "Cannot start the video source", status);382 ErrorAlert(TR("Cannot start the video source"), status); 371 383 return status; 372 384 } 373 385 status = fMediaRoster->StartNode(fVideoConsumer->Node(), perf); 374 386 if (status != B_OK) { 375 ErrorAlert( "Cannot start the video window", status);387 ErrorAlert(TR("Cannot start the video window"), status); 376 388 return status; 377 389 } 378 390 … … 389 401 390 402 if (fVideoConsumer) { 391 403 /* stop */ 392 INFO( "stopping nodes!\n");404 INFO(TR("stopping nodes!\n")); 393 405 // fMediaRoster->StopNode(fProducerNode, 0, true); 394 406 fMediaRoster->StopNode(fVideoConsumer->Node(), 0, true); 395 407 … … 398 410 fConsumerIn.node.node, fConsumerIn.destination); 399 411 400 412 if (fProducerNode != media_node::null) { 401 INFO( "CodyCam releasing fProducerNode\n");413 INFO(TR("CodyCam releasing fProducerNode\n")); 402 414 fMediaRoster->ReleaseNode(fProducerNode); 403 415 fProducerNode = media_node::null; 404 416 } … … 436 448 BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), "menu bar"); 437 449 438 450 BMenuItem* menuItem; 439 BMenu* menu = new BMenu( "File");451 BMenu* menu = new BMenu(TR("File")); 440 452 441 menuItem = new BMenuItem("Video settings", new BMessage(msg_video), 'P'); 453 menuItem = new BMenuItem(TR("Video settings"), new BMessage(msg_video), 454 'P'); 442 455 menuItem->SetTarget(be_app); 443 456 menu->AddItem(menuItem); 444 457 445 458 menu->AddSeparatorItem(); 446 459 447 menuItem = new BMenuItem( "Start video", new BMessage(msg_start), 'A');460 menuItem = new BMenuItem(TR("Start video"), new BMessage(msg_start), 'A'); 448 461 menuItem->SetTarget(be_app); 449 462 menu->AddItem(menuItem); 450 463 451 menuItem = new BMenuItem( "Stop video", new BMessage(msg_stop), 'O');464 menuItem = new BMenuItem(TR("Stop video"), new BMessage(msg_stop), 'O'); 452 465 menuItem->SetTarget(be_app); 453 466 menu->AddItem(menuItem); 454 467 455 468 menu->AddSeparatorItem(); 456 469 457 menuItem = new BMenuItem( "About Codycam" B_UTF8_ELLIPSIS,470 menuItem = new BMenuItem(TR("About Codycam" B_UTF8_ELLIPSIS), 458 471 new BMessage(msg_about), 'B'); 459 472 menuItem->SetTarget(be_app); 460 473 menu->AddItem(menuItem); 461 474 462 475 menu->AddSeparatorItem(); 463 476 464 menuItem = new BMenuItem( "Quit", new BMessage(B_QUIT_REQUESTED), 'Q');477 menuItem = new BMenuItem(TR("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q'); 465 478 menuItem->SetTarget(be_app); 466 479 menu->AddItem(menuItem); 467 480 468 481 menuBar->AddItem(menu); 469 482 470 483 /* give it a gray background view */ 471 fView = new BView( "Background View", B_WILL_DRAW);484 fView = new BView(TR("Background View"), B_WILL_DRAW); 472 485 fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 473 486 474 487 /* add some controls */ … … 508 521 case msg_filename: 509 522 if (control != NULL) { 510 523 strncpy(fFtpInfo.fileNameText, ((BTextControl*)control)->Text(), 63); 511 FTPINFO( "file is '%s'\n", fFtpInfo.fileNameText);524 FTPINFO(TR("file is '%s'\n"), fFtpInfo.fileNameText); 512 525 } 513 526 break; 514 527 515 528 case msg_rate_15s: 516 FTPINFO( "fifteen seconds\n");529 FTPINFO(TR("fifteen seconds\n")); 517 530 fFtpInfo.rate = (bigtime_t)(15 * 1000000); 518 531 break; 519 532 520 533 case msg_rate_30s: 521 FTPINFO( "thirty seconds\n");534 FTPINFO(TR("thirty seconds\n")); 522 535 fFtpInfo.rate = (bigtime_t)(30 * 1000000); 523 536 break; 524 537 525 538 case msg_rate_1m: 526 FTPINFO( "one minute\n");539 FTPINFO(TR("one minute\n")); 527 540 fFtpInfo.rate = (bigtime_t)(1 * 60 * 1000000); 528 541 break; 529 542 530 543 case msg_rate_5m: 531 FTPINFO( "five minute\n");544 FTPINFO(TR("five minute\n")); 532 545 fFtpInfo.rate = (bigtime_t)(5 * 60 * 1000000); 533 546 break; 534 547 535 548 case msg_rate_10m: 536 FTPINFO( "ten minute\n");549 FTPINFO(TR("ten minute\n")); 537 550 fFtpInfo.rate = (bigtime_t)(10 * 60 * 1000000); 538 551 break; 539 552 540 553 case msg_rate_15m: 541 FTPINFO( "fifteen minute\n");554 FTPINFO(TR("fifteen minute\n")); 542 555 fFtpInfo.rate = (bigtime_t)(15 * 60 * 1000000); 543 556 break; 544 557 545 558 case msg_rate_30m: 546 FTPINFO( "thirty minute\n");559 FTPINFO(TR("thirty minute\n")); 547 560 fFtpInfo.rate = (bigtime_t)(30 * 60 * 1000000); 548 561 break; 549 562 550 563 case msg_rate_1h: 551 FTPINFO( "one hour\n");564 FTPINFO(TR("one hour\n")); 552 565 fFtpInfo.rate = (bigtime_t)(60LL * 60LL * 1000000LL); 553 566 break; 554 567 555 568 case msg_rate_2h: 556 FTPINFO( "two hour\n");569 FTPINFO(TR("two hour\n")); 557 570 fFtpInfo.rate = (bigtime_t)(2LL * 60LL * 60LL * 1000000LL); 558 571 break; 559 572 560 573 case msg_rate_4h: 561 FTPINFO( "four hour\n");574 FTPINFO(TR("four hour\n")); 562 575 fFtpInfo.rate = (bigtime_t)(4LL * 60LL * 60LL * 1000000LL); 563 576 break; 564 577 565 578 case msg_rate_8h: 566 FTPINFO( "eight hour\n");579 FTPINFO(TR("eight hour\n")); 567 580 fFtpInfo.rate = (bigtime_t)(8LL * 60LL * 60LL * 1000000LL); 568 581 break; 569 582 570 583 case msg_rate_24h: 571 FTPINFO( "24 hour\n");584 FTPINFO(TR("24 hour\n")); 572 585 fFtpInfo.rate = (bigtime_t)(24LL * 60LL * 60LL * 1000000LL); 573 586 break; 574 587 575 588 case msg_rate_never: 576 FTPINFO( "never\n");589 FTPINFO(TR("never\n")); 577 590 fFtpInfo.rate = (bigtime_t)(B_INFINITE_TIMEOUT); 578 591 break; 579 592 … … 584 597 585 598 case msg_upl_client: 586 599 message->FindInt32("client", &(fFtpInfo.uploadClient)); 587 FTPINFO( "upl client = %ld\n", fFtpInfo.uploadClient);600 FTPINFO(TR("upl client = %ld\n"), fFtpInfo.uploadClient); 588 601 _UploadClientChanged(); 589 602 break; 590 603 591 604 case msg_server: 592 605 if (control != NULL) { 593 606 strncpy(fFtpInfo.serverText, ((BTextControl*)control)->Text(), 64); 594 FTPINFO( "server = '%s'\n", fFtpInfo.serverText);607 FTPINFO(TR("server = '%s'\n"), fFtpInfo.serverText); 595 608 } 596 609 break; 597 610 598 611 case msg_login: 599 612 if (control != NULL) { 600 613 strncpy(fFtpInfo.loginText, ((BTextControl*)control)->Text(), 64); 601 FTPINFO( "login = '%s'\n", fFtpInfo.loginText);614 FTPINFO(TR("login = '%s'\n"), fFtpInfo.loginText); 602 615 } 603 616 break; 604 617 605 618 case msg_password: 606 619 if (control != NULL) { 607 620 strncpy(fFtpInfo.passwordText, ((BTextControl*)control)->Text(), 64); 608 FTPINFO( "password = '%s'\n", fFtpInfo.passwordText);621 FTPINFO(TR("password = '%s'\n"), fFtpInfo.passwordText); 609 622 } 610 623 break; 611 624 612 625 case msg_directory: 613 626 if (control != NULL) { 614 627 strncpy(fFtpInfo.directoryText, ((BTextControl*)control)->Text(), 64); 615 FTPINFO( "directory = '%s'\n", fFtpInfo.directoryText);628 FTPINFO(TR("directory = '%s'\n"), fFtpInfo.directoryText); 616 629 } 617 630 break; 618 631 … … 620 633 if (control != NULL) { 621 634 fFtpInfo.passiveFtp = ((BCheckBox*)control)->Value(); 622 635 if (fFtpInfo.passiveFtp) 623 FTPINFO( "using passive ftp\n");636 FTPINFO(TR("using passive ftp\n")); 624 637 } 625 638 break; 626 639 … … 658 671 fVideoView->SetExplicitMaxSize(BSize(VIDEO_SIZE_X, VIDEO_SIZE_Y)); 659 672 660 673 // Capture controls 661 fCaptureSetupBox = new BBox( "Capture Controls", B_WILL_DRAW);662 fCaptureSetupBox->SetLabel( "Capture controls");674 fCaptureSetupBox = new BBox(TR("Capture Controls"), B_WILL_DRAW); 675 fCaptureSetupBox->SetLabel(TR("Capture controls")); 663 676 664 677 BGridLayout *controlsLayout = new BGridLayout(kXBuffer, 0); 665 678 controlsLayout->SetInsets(10, 15, 5, 5); 666 679 fCaptureSetupBox->SetLayout(controlsLayout); 667 680 668 fFileName = new BTextControl( "File Name", "File name:",681 fFileName = new BTextControl(TR("File Name"), TR("File name:"), 669 682 fFilenameSetting->Value(), new BMessage(msg_filename)); 670 683 fFileName->SetTarget(BMessenger(NULL, this)); 671 684 672 fImageFormatMenu = new BPopUpMenu( "Image Format Menu");685 fImageFormatMenu = new BPopUpMenu(TR("Image Format Menu")); 673 686 AddTranslationItems(fImageFormatMenu, B_TRANSLATOR_BITMAP); 674 687 fImageFormatMenu->SetTargetForItems(this); 675 688 … … 682 695 else 683 696 fImageFormatMenu->ItemAt(0)->SetMarked(true); 684 697 685 fImageFormatSelector = new BMenuField("Format", "Format:",698 fImageFormatSelector = new BMenuField("Format", TR("Format:"), 686 699 fImageFormatMenu, NULL); 687 700 688 fCaptureRateMenu = new BPopUpMenu( "Capture Rate Menu");689 fCaptureRateMenu->AddItem(new BMenuItem( "Every 15 seconds",701 fCaptureRateMenu = new BPopUpMenu(TR("Capture Rate Menu")); 702 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[0], 690 703 new BMessage(msg_rate_15s))); 691 fCaptureRateMenu->AddItem(new BMenuItem( "Every 30 seconds",704 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[1], 692 705 new BMessage(msg_rate_30s))); 693 fCaptureRateMenu->AddItem(new BMenuItem( "Every minute",706 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[2], 694 707 new BMessage(msg_rate_1m))); 695 fCaptureRateMenu->AddItem(new BMenuItem( "Every 5 minutes",708 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[3], 696 709 new BMessage(msg_rate_5m))); 697 fCaptureRateMenu->AddItem(new BMenuItem( "Every 10 minutes",710 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[4], 698 711 new BMessage(msg_rate_10m))); 699 fCaptureRateMenu->AddItem(new BMenuItem( "Every 15 minutes",712 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[5], 700 713 new BMessage(msg_rate_15m))); 701 fCaptureRateMenu->AddItem(new BMenuItem( "Every 30 minutes",714 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[6], 702 715 new BMessage(msg_rate_30m))); 703 fCaptureRateMenu->AddItem(new BMenuItem( "Every hour",716 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[7], 704 717 new BMessage(msg_rate_1h))); 705 fCaptureRateMenu->AddItem(new BMenuItem( "Every 2 hours",718 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[8], 706 719 new BMessage(msg_rate_2h))); 707 fCaptureRateMenu->AddItem(new BMenuItem( "Every 4 hours",720 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[9], 708 721 new BMessage(msg_rate_4h))); 709 fCaptureRateMenu->AddItem(new BMenuItem( "Every 8 hours",722 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[10], 710 723 new BMessage(msg_rate_8h))); 711 fCaptureRateMenu->AddItem(new BMenuItem( "Every 24 hours",724 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[11], 712 725 new BMessage(msg_rate_24h))); 713 fCaptureRateMenu->AddItem(new BMenuItem( "Never",726 fCaptureRateMenu->AddItem(new BMenuItem(KCaptureRate[12], 714 727 new BMessage(msg_rate_never))); 715 728 fCaptureRateMenu->SetTargetForItems(this); 716 729 fCaptureRateMenu->FindItem(fCaptureRateSetting->Value())->SetMarked(true); 717 fCaptureRateSelector = new BMenuField( "Rate", "Rate:",730 fCaptureRateSelector = new BMenuField(TR("Rate"), TR("Rate:"), 718 731 fCaptureRateMenu, NULL); 719 732 720 733 controlsLayout->AddItem(fFileName->CreateLabelLayoutItem(), 0, 0); … … 726 739 controlsLayout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, 3, 2); 727 740 728 741 // FTP setup box 729 fFtpSetupBox = new BBox( "FTP Setup", B_WILL_DRAW);742 fFtpSetupBox = new BBox(TR("FTP Setup"), B_WILL_DRAW); 730 743 731 fUploadClientMenu = new BPopUpMenu( "Send to" B_UTF8_ELLIPSIS);744 fUploadClientMenu = new BPopUpMenu(TR("Send to" B_UTF8_ELLIPSIS)); 732 745 for (int i = 0; kUploadClient[i]; i++) { 733 746 BMessage *m = new BMessage(msg_upl_client); 734 747 m->AddInt32("client", i); … … 739 752 fUploadClientSelector = new BMenuField("UploadClient", NULL, 740 753 fUploadClientMenu, NULL); 741 754 742 fFtpSetupBox->SetLabel( "Output");755 fFtpSetupBox->SetLabel(TR("Output")); 743 756 // this doesn't work with the layout manager 744 757 // fFtpSetupBox->SetLabel(fUploadClientSelector); 745 fUploadClientSelector->SetLabel( "Type:");758 fUploadClientSelector->SetLabel(TR("Type:")); 746 759 747 760 BGridLayout *ftpLayout = new BGridLayout(kXBuffer, 0); 748 761 ftpLayout->SetInsets(10, 15, 5, 5); 749 762 fFtpSetupBox->SetLayout(ftpLayout); 750 763 751 fServerName = new BTextControl( "Server", "Server:",764 fServerName = new BTextControl(TR("Server"), TR("Server:"), 752 765 fServerSetting->Value(), new BMessage(msg_server)); 753 766 fServerName->SetTarget(this); 754 767 755 fLoginId = new BTextControl( "Login", "Login:",768 fLoginId = new BTextControl(TR("Login"), TR("Login:"), 756 769 fLoginSetting->Value(), new BMessage(msg_login)); 757 770 fLoginId->SetTarget(this); 758 771 759 fPassword = new BTextControl( "Password", "Password:",772 fPassword = new BTextControl(TR("Password"), TR("Password:"), 760 773 fPasswordSetting->Value(), new BMessage(msg_password)); 761 774 fPassword->SetTarget(this); 762 775 fPassword->TextView()->HideTyping(true); 763 776 // BeOS HideTyping() seems broken, it empties the text 764 777 fPassword->SetText(fPasswordSetting->Value()); 765 778 766 fDirectory = new BTextControl( "Directory", "Directory:",779 fDirectory = new BTextControl(TR("Directory"), TR("Directory:"), 767 780 fDirectorySetting->Value(), new BMessage(msg_directory)); 768 781 fDirectory->SetTarget(this); 769 782 770 fPassiveFtp = new BCheckBox( "Passive FTP", "Passive FTP",783 fPassiveFtp = new BCheckBox(TR("Passive FTP"), TR("Passive FTP"), 771 784 new BMessage(msg_passiveftp)); 772 785 fPassiveFtp->SetTarget(this); 773 786 fPassiveFtp->SetValue(fPassiveFtpSetting->Value()); … … 784 797 ftpLayout->AddItem(fDirectory->CreateTextViewLayoutItem(), 1, 4); 785 798 ftpLayout->AddView(fPassiveFtp, 0, 5, 2); 786 799 787 fStatusLine = new BStringView( "Status Line", "Waiting" B_UTF8_ELLIPSIS);800 fStatusLine = new BStringView(TR("Status Line"), TR("Waiting" B_UTF8_ELLIPSIS)); 788 801 789 802 BGroupLayout *groupLayout = new BGroupLayout(B_VERTICAL); 790 803 groupLayout->SetInsets(kXBuffer, kYBuffer, kXBuffer, kYBuffer); … … 834 847 fSettings = new Settings(filename, dirname); 835 848 836 849 fServerSetting = new StringValueSetting("Server", "ftp.my.server", 837 "server address expected", "");850 TR("server address expected"), ""); 838 851 fLoginSetting = new StringValueSetting("Login", "loginID", 839 "login ID expected", "");840 fPasswordSetting = new StringValueSetting("Password", "password",841 "password expected", "");852 TR("login ID expected"), ""); 853 fPasswordSetting = new StringValueSetting("Password", TR("password"), 854 TR("password expected"), ""); 842 855 fDirectorySetting = new StringValueSetting("Directory", "web/images", 843 "destination directory expected", "");856 TR("destination directory expected"), ""); 844 857 fPassiveFtpSetting = new BooleanValueSetting("PassiveFtp", 1); 845 858 fFilenameSetting = new StringValueSetting("StillImageFilename", 846 "codycam.jpg", "still image filename expected", "");859 "codycam.jpg", TR("still image filename expected"), ""); 847 860 fImageFormatSettings = new StringValueSetting("ImageFileFormat", 848 "JPEG image", "image file format expected", "");861 TR("JPEG image"), TR("image file format expected"), ""); 849 862 fCaptureRateSetting = new EnumeratedStringValueSetting("CaptureRate", 850 "Every 5 minutes", kCaptureRate, "capture rate expected",851 "unrecognized capture rate specified");863 TR("Every 5 minutes"), kCaptureRate, TR("capture rate expected"), 864 TR("unrecognized capture rate specified")); 852 865 fUploadClientSetting = new EnumeratedStringValueSetting("UploadClient", 853 "FTP", kUploadClient, "upload client name expected",854 "unrecognized upload client specified");866 TR("FTP"), kUploadClient, TR("upload client name expected"), 867 TR("unrecognized upload client specified")); 855 868 856 869 fSettings->Add(fServerSetting); 857 870 fSettings->Add(fLoginSetting); … … 900 913 // #pragma mark - 901 914 902 915 903 ControlWindow::ControlWindow(const BRect& frame, BView* controls, media_node node) 904 : BWindow(frame, "Video settings", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) 916 ControlWindow::ControlWindow(const BRect& frame, BView* controls, 917 media_node node) 918 : BWindow(frame, TR("Video settings"), B_TITLED_WINDOW, 919 B_ASYNCHRONOUS_CONTROLS) 905 920 { 906 921 fView = controls; 907 922 fNode = node; -
src/apps/codycam/SftpClient.h
5 5 #include <stdio.h> 6 6 #include <string> 7 7 8 #include <Catalog.h> 8 9 #include <File.h> 10 #include <Locale.h> 11 9 12 #include "SpawningUploadClient.h" 10 13 14 #undef TR_CONTEXT 15 #define TR_CONTEXT "SftpClient" 16 11 17 using std::string; 12 18 13 19 … … 34 40 void SetPassive(bool on); 35 41 36 42 protected: 43 private: 44 const char *GetReplyText() {return TR("reply: '%s'\n");}; 45 const char *GetReadText() {return TR("read: %d\n");}; 46 const char *GetLReadText() {return TR("read: %ld\n");}; 37 47 38 48 }; 39 49 -
src/apps/codycam/VideoConsumer.cpp
16 16 #include <Application.h> 17 17 #include <Buffer.h> 18 18 #include <BufferGroup.h> 19 #include <Catalog.h> 20 #include <Locale.h> 19 21 #include <MediaRoster.h> 20 22 #include <NodeInfo.h> 21 23 #include <scheduler.h> … … 32 34 #define PROGRESS printf 33 35 #define LOOP printf 34 36 37 #undef TR_CONTEXT 38 #define TR_CONTEXT "VideoConsumer" 39 35 40 static status_t SetFileType(BFile* file, int32 translator, uint32 type); 36 41 37 42 const media_raw_video_format vid_format = {29.97, 1, 0, 239, B_VIDEO_TOP_LEFT_RIGHT, 38 43 1, 1, {B_RGB16, 320, 240, 320 * 4, 0, 0}}; 39 44 40 45 41 VideoConsumer::VideoConsumer(const char* name, BView* view, BStringView* statusLine, 42 BMediaAddOn* addon, const uint32 internalId) 43 : BMediaNode(name), BMediaEventLooper(), BBufferConsumer(B_MEDIA_RAW_VIDEO), 46 VideoConsumer::VideoConsumer(const char* name, 47 BView* view, BStringView* statusLine, BMediaAddOn* addon, 48 const uint32 internalId) 49 : BMediaNode(name), BMediaEventLooper(), 50 BBufferConsumer(B_MEDIA_RAW_VIDEO), 44 51 fStatusLine(statusLine), 45 52 fInternalID(internalId), 46 53 fAddOn(addon), … … 86 93 Quit(); 87 94 88 95 if (fWindow) { 89 printf( "Locking the window\n");96 printf(TR("Locking the window\n")); 90 97 if (fWindow->Lock()) { 91 printf( "Closing the window\n");98 printf(TR("Closing the window\n")); 92 99 fWindow->Close(); 93 100 fWindow = 0; 94 101 } … … 179 186 status_t 180 187 VideoConsumer::RequestCompleted(const media_request_info& info) 181 188 { 182 FUNCTION("VideoConsumer::RequestCompleted\n"); 189 const char *classfunc = "VideoConsumer::RequestCompleted"; 190 FUNCTION("%s\n", classfunc); 183 191 switch (info.what) { 184 192 case media_request_info::B_SET_OUTPUT_BUFFERS_FOR: 185 193 if (info.status != B_OK) 186 ERROR( "VideoConsumer::RequestCompleted: Not using our buffers!\n");194 ERROR(TR("%s: Not using our buffers!\n"), classfunc); 187 195 break; 188 196 189 197 default: 190 ERROR( "VideoConsumer::RequestCompleted: Invalid argument\n");198 ERROR(TR("%s: Invalid argument\n"), classfunc); 191 199 break; 192 200 } 193 201 return B_OK; … … 197 205 status_t 198 206 VideoConsumer::HandleMessage(int32 message, const void* data, size_t size) 199 207 { 200 //FUNCTION("VideoConsumer::HandleMessage\n"); 208 const char *classfunc = "VideoConsumer::HandleMessage"; 209 //FUNCTION("%s\n", classfunc); 201 210 ftp_msg_info* info = (ftp_msg_info*)data; 202 211 status_t status = B_OK; 203 212 204 213 switch (message) { 205 214 case FTP_INFO: 206 PROGRESS( "VideoConsumer::HandleMessage - FTP_INFO message\n");215 PROGRESS(TR("%s - FTP_INFO message\n"), classfunc); 207 216 fRate = info->rate; 208 217 fImageFormat = info->imageFormat; 209 218 fTranslator = info->translator; … … 234 243 void 235 244 VideoConsumer::BufferReceived(BBuffer* buffer) 236 245 { 237 LOOP("VideoConsumer::Buffer #%ld received, start_time %Ld\n", buffer->ID(), buffer->Header()->start_time); 246 const char *classfunc = "VideoConsumer::BufferReceived"; 247 LOOP((TR("%s #%ld received, start_time %Ld\n"), classfunc), 248 buffer->ID(), buffer->Header()->start_time); 238 249 239 250 if (RunState() == B_STOPPED) { 240 251 buffer->Recycle(); 241 252 return; 242 253 } 243 254 244 media_timed_event event(buffer->Header()->start_time, BTimedEventQueue::B_HANDLE_BUFFER, 255 media_timed_event event(buffer->Header()->start_time, 256 BTimedEventQueue::B_HANDLE_BUFFER, 245 257 buffer, BTimedEventQueue::B_RECYCLE_BUFFER); 246 258 EventQueue()->AddEvent(event); 247 259 } 248 260 249 261 250 262 void 251 VideoConsumer::ProducerDataStatus(const media_destination& forWhom, int32 status,252 bigtime_t atMediaTime)263 VideoConsumer::ProducerDataStatus(const media_destination& forWhom, 264 int32 status, bigtime_t atMediaTime) 253 265 { 254 266 FUNCTION("VideoConsumer::ProducerDataStatus\n"); 255 267 … … 261 273 status_t 262 274 VideoConsumer::CreateBuffers(const media_format& withFormat) 263 275 { 264 FUNCTION("VideoConsumer::CreateBuffers\n"); 276 const char *classfunc = "VideoConsumer::CreateBuffers"; 277 FUNCTION("%s\n", classfunc); 265 278 266 279 DeleteBuffers(); 267 280 // delete any old buffers … … 272 285 uint32 xSize = withFormat.u.raw_video.display.line_width; 273 286 uint32 ySize = withFormat.u.raw_video.display.line_count; 274 287 color_space colorspace = withFormat.u.raw_video.display.format; 275 PROGRESS( "VideoConsumer::CreateBuffers - Colorspace = %d\n", colorspace);288 PROGRESS((TR("%s - Colorspace = %d\n"), classfunc), colorspace); 276 289 277 290 fBuffers = new BBufferGroup(); 278 291 status = fBuffers->InitCheck(); 279 292 if (status != B_OK) { 280 ERROR( "VideoConsumer::CreateBuffers - ERROR CREATING BUFFER GROUP\n");293 ERROR(TR("%s - ERROR CREATING BUFFER GROUP\n"), classfunc); 281 294 return status; 282 295 } 283 296 // and attach the bitmaps to the buffer group … … 287 300 if (fBitmap[j]->IsValid()) { 288 301 buffer_clone_info info; 289 302 if ((info.area = area_for(fBitmap[j]->Bits())) == B_ERROR) 290 ERROR( "VideoConsumer::CreateBuffers - ERROR IN AREA_FOR\n");303 ERROR(TR("%s - ERROR IN AREA_FOR\n"), classfunc); 291 304 info.offset = 0; 292 305 info.size = (size_t)fBitmap[j]->BitsLength(); 293 306 info.flags = j; 294 307 info.buffer = 0; 295 308 296 309 if ((status = fBuffers->AddBuffer(info)) != B_OK) { 297 ERROR( "VideoConsumer::CreateBuffers - ERROR ADDING BUFFER TO GROUP\n");310 ERROR(TR("%s - ERROR ADDING BUFFER TO GROUP\n"), classfunc); 298 311 return status; 299 312 } 300 313 else 301 PROGRESS( "VideoConsumer::CreateBuffers - SUCCESSFUL ADD BUFFER TO GROUP\n");314 PROGRESS(TR("%s - SUCCESSFUL ADD BUFFER TO GROUP\n"), classfunc); 302 315 } else { 303 ERROR( "VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING BUFFER: %08lx\n",304 status);316 ERROR((TR("%s - ERROR CREATING VIDEO RING BUFFER: " 317 "%08lx\n"), classfunc), status); 305 318 return B_ERROR; 306 319 } 307 320 } … … 314 327 for (int j = 0; j < 3; j++) 315 328 if (buffList[j] != NULL) { 316 329 fBufferMap[j] = (uint32)buffList[j]; 317 PROGRESS( " j = %d buffer = %08lx\n", j, fBufferMap[j]);330 PROGRESS(TR(" j = %d buffer = %08lx\n"), j, fBufferMap[j]); 318 331 } else { 319 ERROR( "VideoConsumer::CreateBuffers ERROR MAPPING RING BUFFER\n");332 ERROR(TR("%s ERROR MAPPING RING BUFFER\n"), classfunc); 320 333 return B_ERROR; 321 334 } 322 335 else 323 ERROR( "VideoConsumer::CreateBuffers ERROR IN GET BUFFER LIST\n");336 ERROR(TR("%s ERROR IN GET BUFFER LIST\n"), classfunc); 324 337 325 fFtpBitmap = new BBitmap(BRect(0, 0, xSize - 1, ySize - 1), B_RGB32, false, false); 338 fFtpBitmap = new BBitmap(BRect(0, 0, xSize - 1, ySize - 1), B_RGB32, 339 false, false); 326 340 327 FUNCTION( "VideoConsumer::CreateBuffers - EXIT\n");341 FUNCTION(TR("%s - EXIT\n"), classfunc); 328 342 return status; 329 343 } 330 344 … … 332 346 void 333 347 VideoConsumer::DeleteBuffers() 334 348 { 335 FUNCTION("VideoConsumer::DeleteBuffers\n"); 349 const char *classfunc = "VideoConsumer::DeleteBuffers"; 350 FUNCTION("%s\n", classfunc); 336 351 337 352 if (fBuffers) { 338 353 delete fBuffers; … … 344 359 fBitmap[j] = NULL; 345 360 } 346 361 } 347 FUNCTION( "VideoConsumer::DeleteBuffers - EXIT\n");362 FUNCTION(TR("%s - EXIT\n"), classfunc); 348 363 } 349 364 350 365 … … 352 367 VideoConsumer::Connected(const media_source& producer, const media_destination& where, 353 368 const media_format& withFormat, media_input* outInput) 354 369 { 355 FUNCTION("VideoConsumer::Connected\n"); 370 const char *classfunc = "VideoConsumer::Connected"; 371 FUNCTION("%s\n", classfunc); 356 372 357 373 fIn.source = producer; 358 374 fIn.format = withFormat; 359 375 fIn.node = Node(); 360 sprintf(fIn.name, "Video Consumer");376 sprintf(fIn.name, TR("Video Consumer")); 361 377 *outInput = fIn; 362 378 363 379 uint32 userData = 0; … … 366 382 BBufferConsumer::SetOutputBuffersFor(producer, fDestination, 367 383 fBuffers, (void *)&userData, &changeTag, true); 368 384 else { 369 ERROR( "VideoConsumer::Connected - COULDN'T CREATE BUFFERS\n");385 ERROR(TR("%s - COULDN'T CREATE BUFFERS\n"), classfunc); 370 386 return B_ERROR; 371 387 } 372 388 373 389 fConnectionActive = true; 374 390 375 FUNCTION( "VideoConsumer::Connected - EXIT\n");391 FUNCTION(TR("%s - EXIT\n"), classfunc); 376 392 return B_OK; 377 393 } 378 394 … … 395 411 status_t 396 412 VideoConsumer::AcceptFormat(const media_destination& dest, media_format* format) 397 413 { 398 FUNCTION("VideoConsumer::AcceptFormat\n"); 414 const char *classfunc = "VideoConsumer::AcceptFormat"; 415 FUNCTION("%s\n", classfunc); 399 416 400 417 if (dest != fIn.destination) { 401 ERROR( "VideoConsumer::AcceptFormat - BAD DESTINATION\n");418 ERROR(TR("%s - BAD DESTINATION\n"), classfunc); 402 419 return B_MEDIA_BAD_DESTINATION; 403 420 } 404 421 … … 406 423 format->type = B_MEDIA_RAW_VIDEO; 407 424 408 425 if (format->type != B_MEDIA_RAW_VIDEO) { 409 ERROR( "VideoConsumer::AcceptFormat - BAD FORMAT\n");426 ERROR(TR("%s - BAD FORMAT\n"), classfunc); 410 427 return B_MEDIA_BAD_FORMAT; 411 428 } 412 429 … … 416 433 && format->u.raw_video.display.format != B_GRAY8 417 434 && 418 435 format->u.raw_video.display.format != media_raw_video_format::wildcard.display.format) { 419 ERROR( "AcceptFormat - not a format we know about!\n");436 ERROR(TR("AcceptFormat - not a format we know about!\n")); 420 437 return B_MEDIA_BAD_FORMAT; 421 438 } 422 439 … … 426 443 427 444 char formatString[256]; 428 445 string_for_format(*format, formatString, 256); 429 FUNCTION(" VideoConsumer::AcceptFormat: %s\n", formatString);446 FUNCTION("%s: %s\n", classfunc, formatString); 430 447 431 448 return B_OK; 432 449 } … … 435 452 status_t 436 453 VideoConsumer::GetNextInput(int32* cookie, media_input* outInput) 437 454 { 438 FUNCTION("VideoConsumer::GetNextInput\n"); 455 const char *classfunc = "VideoConsumer::GetNextInput"; 456 FUNCTION("%s\n", classfunc); 439 457 440 458 // custom build a destination for this connection 441 459 // put connection number in id … … 443 461 if (*cookie < 1) { 444 462 fIn.node = Node(); 445 463 fIn.destination.id = *cookie; 446 sprintf(fIn.name, "Video Consumer");464 sprintf(fIn.name, TR("Video Consumer")); 447 465 *outInput = fIn; 448 466 (*cookie)++; 449 467 return B_OK; 450 468 } else { 451 ERROR( "VideoConsumer::GetNextInput - - BAD INDEX\n");469 ERROR(TR("%s - - BAD INDEX\n"), classfunc); 452 470 return B_MEDIA_BAD_DESTINATION; 453 471 } 454 472 } … … 497 515 VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness, 498 516 bool realTimeEvent) 499 517 { 500 LOOP("VideoConsumer::HandleEvent\n"); 518 const char *classfunc = "VideoConsumer::HandleEvent"; 519 LOOP("%s\n", classfunc); 501 520 502 521 BBuffer* buffer; 503 522 504 523 switch (event->type) { 505 524 case BTimedEventQueue::B_START: 506 PROGRESS( "VideoConsumer::HandleEvent - START\n");525 PROGRESS(TR("%s - START\n"), classfunc); 507 526 break; 508 527 509 528 case BTimedEventQueue::B_STOP: 510 PROGRESS( "VideoConsumer::HandleEvent - STOP\n");529 PROGRESS(TR("%s - STOP\n"), classfunc); 511 530 EventQueue()->FlushEvents(event->event_time, BTimedEventQueue::B_ALWAYS, 512 531 true, BTimedEventQueue::B_HANDLE_BUFFER); 513 532 break; 514 533 515 534 case BTimedEventQueue::B_USER_EVENT: 516 PROGRESS( "VideoConsumer::HandleEvent - USER EVENT\n");535 PROGRESS(TR("%s - USER EVENT\n"), classfunc); 517 536 if (RunState() == B_STARTED) { 518 537 fTimeToFtp = true; 519 PROGRESS( "Pushing user event for %.4f, time now %.4f\n",538 PROGRESS(TR("Pushing user event for %.4f, time now %.4f\n"), 520 539 (event->event_time + fRate) / M1, event->event_time/M1); 521 540 media_timed_event newEvent(event->event_time + fRate, 522 541 BTimedEventQueue::B_USER_EVENT); … … 526 545 527 546 case BTimedEventQueue::B_HANDLE_BUFFER: 528 547 { 529 LOOP( "VideoConsumer::HandleEvent - HANDLE BUFFER\n");548 LOOP(TR("%s - HANDLE BUFFER\n"), classfunc); 530 549 buffer = (BBuffer *)event->pointer; 531 550 if (RunState() == B_STARTED && fConnectionActive) { 532 551 // see if this is one of our buffers … … 545 564 } 546 565 547 566 if (fFtpComplete && fTimeToFtp) { 548 PROGRESS( "VidConsumer::HandleEvent - SPAWNING FTP THREAD\n");567 PROGRESS(TR("%s - SPAWNING FTP THREAD\n"), classfunc); 549 568 fTimeToFtp = false; 550 569 fFtpComplete = false; 551 570 memcpy(fFtpBitmap->Bits(), buffer->Data(), fFtpBitmap->BitsLength()); … … 577 596 } 578 597 } 579 598 else 580 PROGRESS( "VidConsumer::HandleEvent - DROPPED FRAME\n");599 PROGRESS(TR("%s - DROPPED FRAME\n"), classfunc); 581 600 buffer->Recycle(); 582 601 } 583 602 else … … 586 605 } 587 606 588 607 default: 589 ERROR( "VideoConsumer::HandleEvent - BAD EVENT\n");608 ERROR(TR("%s - BAD EVENT\n"), classfunc); 590 609 break; 591 610 } 592 611 } … … 618 637 #if 0 619 638 // save a small version, too 620 639 BBitmap* b = new BBitmap(BRect(0,0,159,119), B_RGB32, true, false); 621 BView* v = new BView(BRect(0,0,159,119), "SmallView 1", 0, B_WILL_DRAW);640 BView* v = new BView(BRect(0,0,159,119), TR("SmallView 1"), 0, B_WILL_DRAW); 622 641 b->AddChild(v); 623 642 624 643 b->Lock(); … … 639 658 void 640 659 VideoConsumer::UpdateFtpStatus(const char* status) 641 660 { 642 printf( "FTP STATUS: %s\n",status);661 printf(TR("FTP STATUS: %s\n"),status); 643 662 if (fView->Window()->Lock()) { 644 663 fStatusLine->SetText(status); 645 664 fView->Window()->Unlock(); … … 652 671 { 653 672 BFile* output; 654 673 655 UpdateFtpStatus( "Capturing Image" B_UTF8_ELLIPSIS);674 UpdateFtpStatus(TR("Capturing Image" B_UTF8_ELLIPSIS)); 656 675 657 676 /* save a local copy of the image in the requested format */ 658 677 output = new BFile(); … … 663 682 if (err == B_OK) { 664 683 err = SetFileType(output, fTranslator, fImageFormat); 665 684 if (err != B_OK) 666 UpdateFtpStatus( "Error setting type of output file");685 UpdateFtpStatus(TR("Error setting type of output file")); 667 686 } 668 687 else 669 UpdateFtpStatus( "Error writing output file");688 UpdateFtpStatus(TR("Error writing output file")); 670 689 671 690 input.DetachBitmap(&bitmap); 672 691 output->Unset(); 673 692 delete output; 674 693 return B_OK; 675 694 } else { 676 UpdateFtpStatus( "Error creating output file");695 UpdateFtpStatus(TR("Error creating output file")); 677 696 return B_ERROR; 678 697 } 679 698 } … … 695 714 case 2: 696 715 return B_OK; 697 716 default: 698 fprintf(stderr, "invalid upload client %ld\n", fUploadClient);717 fprintf(stderr, TR("invalid upload client %ld\n"), fUploadClient); 699 718 return EINVAL; 700 719 } 701 720 702 721 ftp->SetPassive(fPassiveFtp); 703 722 // ftp the local file to our web site 704 723 705 UpdateFtpStatus( "Logging in" B_UTF8_ELLIPSIS);724 UpdateFtpStatus(TR("Logging in" B_UTF8_ELLIPSIS)); 706 725 if (ftp->Connect((string)fServerText, (string)fLoginText, (string)fPasswordText)) { 707 726 // connect to server 708 UpdateFtpStatus( "Connected" B_UTF8_ELLIPSIS);727 UpdateFtpStatus(TR("Connected" B_UTF8_ELLIPSIS)); 709 728 710 729 if (ftp->ChangeDir((string)fDirectoryText)) { 711 730 // cd to the desired directory 712 UpdateFtpStatus( "Transmitting" B_UTF8_ELLIPSIS);731 UpdateFtpStatus(TR("Transmitting" B_UTF8_ELLIPSIS)); 713 732 714 733 if (ftp->PutFile((string)filename, (string)"temp")) { 715 734 // send the file to the server … … 717 736 ftp->Chmod((string)"temp", (string)"644"); 718 737 // make it world readable 719 738 720 UpdateFtpStatus( "Renaming" B_UTF8_ELLIPSIS);739 UpdateFtpStatus(TR("Renaming" B_UTF8_ELLIPSIS)); 721 740 722 741 if (ftp->MoveFile((string)"temp", (string)filename)) { 723 742 // change to the desired name 724 743 uint32 time = real_time_clock(); 725 744 char s[80]; 726 strcpy(s, "Last Capture: ");745 strcpy(s, TR("Last Capture: ")); 727 746 strcat(s, ctime((const long*)&time)); 728 747 s[strlen(s) - 1] = 0; 729 748 UpdateFtpStatus(s); … … 731 750 return B_OK; 732 751 } 733 752 else 734 UpdateFtpStatus( "Rename failed");753 UpdateFtpStatus(TR("Rename failed")); 735 754 } 736 755 else 737 UpdateFtpStatus( "File transmission failed");756 UpdateFtpStatus(TR("File transmission failed")); 738 757 } 739 758 else 740 UpdateFtpStatus( "Couldn't find requested directory on server");759 UpdateFtpStatus(TR("Couldn't find requested directory on server")); 741 760 } 742 761 else 743 UpdateFtpStatus( "Server login failed");762 UpdateFtpStatus(TR("Server login failed")); 744 763 745 764 delete ftp; 746 765 return B_ERROR; -
src/apps/codycam/CodyCam.h
9 9 10 10 #include <Application.h> 11 11 #include <Box.h> 12 #include <Catalog.h> 12 13 #include <CheckBox.h> 14 #include <Locale.h> 13 15 #include <Menu.h> 14 16 #include <MenuField.h> 15 17 #include <StringView.h> … … 19 21 20 22 class BMediaRoster; 21 23 24 #undef TR_CONTEXT 25 #define TR_CONTEXT "CodyCam" 22 26 23 27 enum { 24 28 msg_filename = 'file', … … 59 63 60 64 61 65 const char* kCaptureRate[] = { 62 "Every 15 seconds",63 "Every 30 seconds",64 "Every minute",65 "Every 5 minutes",66 "Every 10 minutes",67 "Every 15 minutes",68 "Every 30 minutes",69 "Every hour",70 "Every 2 hours",71 "Every 4 hours",72 "Every 8 hours",73 "Every 24 hours",74 "Never",66 TR("Every 15 seconds"), 67 TR("Every 30 seconds"), 68 TR("Every minute"), 69 TR("Every 5 minutes"), 70 TR("Every 10 minutes"), 71 TR("Every 15 minutes"), 72 TR("Every 30 minutes"), 73 TR("Every hour"), 74 TR("Every 2 hours"), 75 TR("Every 4 hours"), 76 TR("Every 8 hours"), 77 TR("Every 24 hours"), 78 TR("Never"), 75 79 0 76 80 }; 77 81 78 82 79 83 const char* kUploadClient[] = { 80 "FTP",81 "SFTP",82 "Local",84 TR("FTP"), 85 TR("SFTP"), 86 TR("Local"), 83 87 0 84 88 }; 85 89 … … 106 110 BWindow* fWindow; 107 111 port_id fPort; 108 112 BWindow* fVideoControlWindow; 113 BCatalog fAppCatalog; 109 114 }; 110 115 111 116 -
src/apps/codycam/FtpClient.cpp
1 1 #include "FtpClient.h" 2 2 3 #include <Catalog.h> 4 #include <Locale.h> 5 3 6 #include <stdlib.h> 4 7 #include <string.h> 5 8 9 #undef TR_CONTEXT 10 #define TR_CONTEXT "FtpClient" 11 6 12 FtpClient::FtpClient() 7 13 : FileUploadClient(), 8 14 fState(0), … … 111 117 112 118 113 119 bool 114 FtpClient::Connect(const string& server, const string& login, const string& passwd) 120 FtpClient::Connect(const string& server, 121 const string& login, 122 const string& passwd) 115 123 { 116 124 bool rc = false; 117 125 int code, codeType; … … 373 381 374 382 if (path.length() == 0) 375 383 cmd += '/'; 376 printf( "cmd: '%s'\n", cmd.c_str());384 printf(TR("cmd: '%s'\n"), cmd.c_str()); 377 385 if (_SendRequest(cmd) == true) { 378 386 if (_GetReply(replyString, code, codeType) == true) { 379 printf( "reply: %d, %d\n", code, codeType);387 printf(TR("reply: %d, %d\n"), code, codeType); 380 388 if (codeType == 2) 381 389 rc = true; 382 390 } … … 424 432 425 433 if (fControl != 0) { 426 434 if (cmd.find("PASS") != string::npos) 427 printf( "PASS <suppressed> (real password sent)\n");435 printf(TR("PASS <suppressed> (real password sent)\n")); 428 436 else 429 437 printf("%s\n", ccmd.c_str()); 430 438 … … 540 548 } 541 549 542 550 if (!rc && outCode != 421) { 543 outString += "Remote host has closed the connection.\n";551 outString += TR("Remote host has closed the connection.\n"); 544 552 outCode = 421; 545 553 } 546 554