Ticket #5908: codycamLocalization.2.patch
File codycamLocalization.2.patch, 36.0 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> … … 13 14 #include <Path.h> 14 15 #include <StopWatch.h> 15 16 17 #undef TR_CONTEXT 18 #define TR_CONTEXT "SettingsHandler" 16 19 20 #define B_TRANSLATE(str) \ 21 be_catalog->GetString((str), TR_CONTEXT) 22 17 23 #if 0 18 24 static int 19 25 Compare(const SettingsArgvDispatcher* p1, const SettingsArgvDispatcher* p2) … … 56 62 { 57 63 fFile = fopen(fFileName, "r"); 58 64 if (!fFile) { 59 PRINT(( "Error opening %s\n", fFileName));65 PRINT((B_TRANSLATE("Error opening %s\n"), fFileName)); 60 66 return; 61 67 } 62 68 fBuffer = new char [kBufferSize]; … … 95 101 fCurrentArgv[fArgc] = 0; 96 102 const char *result = (argvHandlerFunc)(fArgc, fCurrentArgv, passThru); 97 103 if (result) 98 printf( "File %s; Line %ld # %s", fFileName, fLineNo, result);104 printf(B_TRANSLATE("File %s; Line %ld # %s"), fFileName, fLineNo, result); 99 105 MakeArgvEmpty(); 100 106 if (result) 101 107 return B_ERROR; … … 148 154 149 155 150 156 status_t 151 ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc, void* passThru) 157 ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc, 158 void* passThru) 152 159 { 153 160 ArgvParser parser(name); 154 161 return parser.EachArgvPrivate(name, argvHandlerFunc, passThru); … … 166 173 if (ch == EOF) { 167 174 // done with file 168 175 if (fInDoubleQuote || fInSingleQuote) { 169 printf("File %s # unterminated quote at end of file\n", name); 176 printf(B_TRANSLATE("File %s # unterminated quote at end of " 177 "file\n"), name); 170 178 result = B_ERROR; 171 179 break; 172 180 } … … 178 186 // handle new line 179 187 fEatComment = false; 180 188 if (!fSawBackslash && (fInDoubleQuote || fInSingleQuote)) { 181 printf("File %s ; Line %ld # unterminated quote\n", name, fLineNo); 189 printf(B_TRANSLATE("File %s ; Line %ld # unterminated " 190 "quote\n"), name, fLineNo); 182 191 result = B_ERROR; 183 192 break; 184 193 } … … 350 359 351 360 SettingsArgvDispatcher* handler = settings->_Find(*argv); 352 361 if (!handler) 353 return "unknown command";362 return B_TRANSLATE("unknown command"); 354 363 return handler->Handle(argv); 355 364 } 356 365 -
src/apps/codycam/Settings.cpp
4 4 #include <stdlib.h> 5 5 #include <string.h> 6 6 7 #include <Catalog.h> 7 8 #include <Debug.h> 9 #include <Locale.h> 8 10 11 #undef TR_CONTEXT 12 #define TR_CONTEXT "Settings" 9 13 14 #define B_TRANSLATE(str) \ 15 be_catalog->GetString((str), TR_CONTEXT) 16 17 #define B_TRANSLATE_CMT(str,cmt) \ 18 be_catalog->GetString((str), TR_CONTEXT, (cmt)) 19 10 20 Settings* settings = NULL; 11 21 12 22 … … 230 240 BooleanValueSetting::Handle(const char *const *argv) 231 241 { 232 242 if (!*++argv) 233 return "on or off expected";243 return B_TRANSLATE_CMT("on or off expected","Do not translate 'on' and 'off'"); 234 244 235 245 if (strcmp(*argv, "on") == 0) 236 246 fValue = true; 237 247 else if (strcmp(*argv, "off") == 0) 238 248 fValue = false; 239 249 else 240 return "on or off expected";250 return B_TRANSLATE_CMT("on or off expected", "Do not translate 'on' and 'off'"); 241 251 242 252 return 0; 243 253 } -
src/apps/codycam/SftpClient.cpp
26 26 cmd << " " << dir.c_str() << "\n"; 27 27 SendCommand(cmd.String()); 28 28 if ((len = ReadReply(&reply)) < 0) { 29 fprintf(stderr, "read: %d\n", len);29 fprintf(stderr, GetReadText(), len); 30 30 return false; 31 31 } 32 fprintf(stderr, "reply: '%s'\n", reply.String());32 fprintf(stderr, GetReplyText(), reply.String()); 33 33 if (reply.FindFirst("sftp>") < 0) 34 34 return false; 35 35 rc = true; … … 46 46 BString reply; 47 47 do { 48 48 if ((len = ReadReply(&reply)) < 0) { 49 fprintf(stderr, "read: %d\n", len);49 fprintf(stderr, GetReadText(), len); 50 50 return false; 51 51 } 52 fprintf(stderr, "reply: '%s'\n", reply.String());52 fprintf(stderr, GetReplyText(), reply.String()); 53 53 printf("%s", reply.String()); 54 54 if (reply.FindFirst("sftp>") == 0) 55 55 return true; … … 69 69 70 70 71 71 bool 72 SftpClient::Connect(const string& server, const string& login, const string& passwd) 72 SftpClient::Connect(const string& server, const string& login, 73 const string& passwd) 73 74 { 74 75 bool rc = false; 75 76 BString cmd("sftp "); … … 89 90 ssize_t len; 90 91 91 92 if ((len = ReadReply(&reply)) < 0) { 92 fprintf(stderr, "read: %ld\n", len);93 fprintf(stderr, GetLongReadText(), len); 93 94 return false; 94 95 } 95 fprintf(stderr, "reply: '%s'\n", reply.String());96 fprintf(stderr, GetReplyText(), reply.String()); 96 97 if (reply.FindFirst("Connecting to ") != 0) 97 98 return false; 98 99 99 100 if ((len = ReadReply(&reply)) < 0) { 100 fprintf(stderr, "read: %ld\n", len);101 fprintf(stderr, GetLongReadText(), len); 101 102 return false; 102 103 } 103 fprintf(stderr, "reply: '%s'\n", reply.String());104 fprintf(stderr, GetReplyText(), reply.String()); 104 105 if (reply.FindFirst(/*[pP]*/"assword:") < 0) 105 106 return false; 106 107 … … 108 109 write(OutputPipe(), "\n", 1); 109 110 110 111 if ((len = ReadReply(&reply)) < 0) { 111 fprintf(stderr, "read: %ld\n", len);112 fprintf(stderr, GetLongReadText(), len); 112 113 return false; 113 114 } 114 fprintf(stderr, "reply: '%s'\n", reply.String());115 fprintf(stderr, GetReplyText(), reply.String()); 115 116 if (reply != "\n") 116 117 return false; 117 118 118 119 if ((len = ReadReply(&reply)) < 0) { 119 fprintf(stderr, "read: %ld\n", len);120 fprintf(stderr, GetLongReadText(), len); 120 121 return false; 121 122 } 122 fprintf(stderr, "reply: '%s'\n", reply.String());123 fprintf(stderr, GetReplyText(), reply.String()); 123 124 if (reply.FindFirst("sftp>") < 0) 124 125 return false; 125 126 return rc; … … 138 139 BString reply; 139 140 140 141 if ((len = ReadReply(&reply)) < 0) { 141 fprintf(stderr, "read: %d\n", len);142 fprintf(stderr, GetReadText(), len); 142 143 return false; 143 144 } 144 fprintf(stderr, "reply: '%s'\n", reply.String());145 fprintf(stderr, GetReplyText(), reply.String()); 145 146 if (reply.FindFirst("Uploading") < 0) 146 147 return false; 147 148 148 149 if ((len = ReadReply(&reply)) < 0) { 149 fprintf(stderr, "read: %d\n", len);150 fprintf(stderr, GetReadText(), len); 150 151 return false; 151 152 } 152 fprintf(stderr, "reply: '%s'\n", reply.String());153 fprintf(stderr, GetReplyText(), reply.String()); 153 154 if (reply.FindFirst("sftp>") < 0) 154 155 return false; 155 156 … … 183 184 BString reply; 184 185 185 186 if ((len = ReadReply(&reply)) < 0) { 186 fprintf(stderr, "read: %d\n", len);187 fprintf(stderr, GetReadText(), len); 187 188 return false; 188 189 } 189 fprintf(stderr, "reply: '%s'\n", reply.String());190 fprintf(stderr, GetReplyText(), reply.String()); 190 191 // we don't care if it worked or not. 191 192 //if (reply.FindFirst("Removing") != 0 && reply.FindFirst("Couldn't") ) 192 193 // return false; 193 194 194 195 if ((len = ReadReply(&reply)) < 0) { 195 fprintf(stderr, "read: %d\n", len);196 fprintf(stderr, GetReadText(), len); 196 197 return false; 197 198 } 198 fprintf(stderr, "reply: '%s'\n", reply.String());199 fprintf(stderr, GetReplyText(), reply.String()); 199 200 if (reply.FindFirst("sftp>") < 0) 200 201 return false; 201 202 … … 203 204 cmd << " " << oldPath.c_str() << " " << newPath.c_str() << "\n"; 204 205 SendCommand(cmd.String()); 205 206 if ((len = ReadReply(&reply)) < 0) { 206 fprintf(stderr, "read: %d\n", len);207 fprintf(stderr, GetReadText(), len); 207 208 return false; 208 209 } 209 fprintf(stderr, "reply: '%s'\n", reply.String());210 fprintf(stderr, GetReplyText(), reply.String()); 210 211 if (reply.FindFirst("sftp>") < 0) 211 212 return false; 212 213 rc = true; … … 226 227 BString reply; 227 228 228 229 if ((len = ReadReply(&reply)) < 0) { 229 fprintf(stderr, "read: %d\n", len);230 fprintf(stderr, GetReadText(), len); 230 231 return false; 231 232 } 232 fprintf(stderr, "reply: '%s'\n", reply.String());233 fprintf(stderr, GetReplyText(), reply.String()); 233 234 if (reply.FindFirst("Changing") < 0) 234 235 return false; 235 236 236 237 if ((len = ReadReply(&reply)) < 0) { 237 fprintf(stderr, "read: %d\n", len);238 fprintf(stderr, GetReadText(), len); 238 239 return false; 239 240 } 240 fprintf(stderr, "reply: '%s'\n", reply.String());241 fprintf(stderr, GetReplyText(), reply.String()); 241 242 if (reply.FindFirst("sftp>") < 0) 242 243 return false; 243 244 -
src/apps/codycam/CodyCam.cpp
127 127 fVideoConsumer(NULL), 128 128 fWindow(NULL), 129 129 fPort(0), 130 fVideoControlWindow(NULL) 130 fVideoControlWindow(NULL), 131 fAppCatalog(NULL) 131 132 { 133 be_locale->GetAppCatalog(&fAppCatalog); 132 134 chdir("/boot/home"); 133 135 } 134 136 … … 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*) B_TRANSLATE("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 = fMediaRoster->MakeTimeSourceFor( 184 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); … … 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(B_TRANSLATE("About CodyCam"), B_TRANSLATE("CodyCam\n\n" 223 "The Original BeOS webcam"), B_TRANSLATE("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(B_TRANSLATE("Cannot find the media roster"), status, 248 fWindow); 245 249 return status; 246 250 } 247 251 248 252 /* find the time source */ 249 253 status = fMediaRoster->GetTimeSource(&fTimeSourceNode); 250 254 if (status != B_OK) { 251 ErrorAlert( "Cannot get a time source", status, fWindow);255 ErrorAlert(B_TRANSLATE("Cannot get a time source"), status, fWindow); 252 256 return status; 253 257 } 254 258 … … 256 260 INFO("CodyCam acquiring VideoInput node\n"); 257 261 status = fMediaRoster->GetVideoInput(&fProducerNode); 258 262 if (status != B_OK) { 259 ErrorAlert("Cannot find a video source. You need a webcam to use CodyCam.", status, fWindow); 263 ErrorAlert(B_TRANSLATE("Cannot find a video source. You need a webcam " 264 "to use CodyCam."), status, fWindow); 260 265 return status; 261 266 } 262 267 263 268 /* create the video consumer node */ 264 fVideoConsumer = new VideoConsumer("CodyCam", ((VideoWindow*)fWindow)->VideoView(), 269 fVideoConsumer = new VideoConsumer("CodyCam", 270 ((VideoWindow*)fWindow)->VideoView(), 265 271 ((VideoWindow*)fWindow)->StatusLine(), NULL, 0); 266 272 if (!fVideoConsumer) { 267 ErrorAlert("Cannot create a video window", B_ERROR, fWindow); 273 ErrorAlert(B_TRANSLATE("Cannot create a video window"), B_ERROR, 274 fWindow); 268 275 return B_ERROR; 269 276 } 270 277 271 278 /* register the node */ 272 279 status = fMediaRoster->RegisterNode(fVideoConsumer); 273 280 if (status != B_OK) { 274 ErrorAlert("Cannot register the video window", status, fWindow); 281 ErrorAlert(B_TRANSLATE("Cannot register the video window"), status, 282 fWindow); 275 283 return status; 276 284 } 277 285 fPort = fVideoConsumer->ControlPort(); 278 286 279 287 /* find free producer output */ 280 288 int32 cnt = 0; 281 status = fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1, &cnt,282 B_MEDIA_RAW_VIDEO);289 status = fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1, 290 &cnt, B_MEDIA_RAW_VIDEO); 283 291 if (status != B_OK || cnt < 1) { 284 292 status = B_RESOURCE_UNAVAILABLE; 285 ErrorAlert("Cannot find an available video stream", status, fWindow); 293 ErrorAlert(B_TRANSLATE("Cannot find an available video stream"), 294 status, fWindow); 286 295 return status; 287 296 } 288 297 289 298 /* find free consumer input */ 290 299 cnt = 0; 291 status = fMediaRoster->GetFreeInputsFor(fVideoConsumer->Node(), &fConsumerIn, 1,292 & cnt, B_MEDIA_RAW_VIDEO);300 status = fMediaRoster->GetFreeInputsFor(fVideoConsumer->Node(), 301 &fConsumerIn, 1, &cnt, B_MEDIA_RAW_VIDEO); 293 302 if (status != B_OK || cnt < 1) { 294 303 status = B_RESOURCE_UNAVAILABLE; 295 ErrorAlert("Can't find an available connection to the video window", status, fWindow); 304 ErrorAlert(B_TRANSLATE("Can't find an available connection to the " 305 "video window"), status, fWindow); 296 306 return status; 297 307 } 298 308 … … 304 314 format.u.raw_video = vid_format; 305 315 306 316 /* connect producer to consumer */ 307 status = fMediaRoster->Connect(fProducerOut.source, fConsumerIn.destination,308 317 status = fMediaRoster->Connect(fProducerOut.source, 318 fConsumerIn.destination, &format, &fProducerOut, &fConsumerIn); 309 319 if (status != B_OK) { 310 ErrorAlert("Cannot connect the video source to the video window", status); 320 ErrorAlert(B_TRANSLATE("Cannot connect the video source to the video " 321 "window"), status); 311 322 return status; 312 323 } 313 324 314 325 315 326 /* set time sources */ 316 status = fMediaRoster->SetTimeSourceFor(fProducerNode.node, fTimeSourceNode.node); 327 status = fMediaRoster->SetTimeSourceFor(fProducerNode.node, 328 fTimeSourceNode.node); 317 329 if (status != B_OK) { 318 ErrorAlert("Cannot set the time source for the video source", status); 330 ErrorAlert(B_TRANSLATE("Cannot set the time source for the video " 331 "source"), status); 319 332 return status; 320 333 } 321 334 322 status = fMediaRoster->SetTimeSourceFor(fVideoConsumer->ID(), fTimeSourceNode.node); 335 status = fMediaRoster->SetTimeSourceFor(fVideoConsumer->ID(), 336 fTimeSourceNode.node); 323 337 if (status != B_OK) { 324 ErrorAlert("Cannot set the time source for the video window", status); 338 ErrorAlert(B_TRANSLATE("Cannot set the time source for the video " 339 "window"), status); 325 340 return status; 326 341 } 327 342 … … 334 349 bigtime_t initLatency = 0; 335 350 status = fMediaRoster->GetInitialLatencyFor(fProducerNode, &initLatency); 336 351 if (status < B_OK) { 337 ErrorAlert("Error getting initial latency for the capture node", status); 352 ErrorAlert(B_TRANSLATE("Error getting initial latency for the capture " 353 "node"), status); 338 354 return status; 339 355 } 340 356 … … 350 366 status = fMediaRoster->StartTimeSource(fTimeSourceNode, real); 351 367 if (status != B_OK) { 352 368 timeSource->Release(); 353 ErrorAlert( "Cannot start time source!", status);369 ErrorAlert(B_TRANSLATE("Cannot start time source!"), status); 354 370 return status; 355 371 } 356 372 status = fMediaRoster->SeekTimeSource(fTimeSourceNode, 0, real); 357 373 if (status != B_OK) { 358 374 timeSource->Release(); 359 ErrorAlert( "Cannot seek time source!", status);375 ErrorAlert(B_TRANSLATE("Cannot seek time source!"), status); 360 376 return status; 361 377 } 362 378 } 363 379 364 bigtime_t perf = timeSource->PerformanceTimeFor(real + latency + initLatency); 380 bigtime_t perf = timeSource->PerformanceTimeFor(real + latency 381 + initLatency); 365 382 timeSource->Release(); 366 383 367 384 /* start the nodes */ 368 385 status = fMediaRoster->StartNode(fProducerNode, perf); 369 386 if (status != B_OK) { 370 ErrorAlert( "Cannot start the video source", status);387 ErrorAlert(B_TRANSLATE("Cannot start the video source"), status); 371 388 return status; 372 389 } 373 390 status = fMediaRoster->StartNode(fVideoConsumer->Node(), perf); 374 391 if (status != B_OK) { 375 ErrorAlert( "Cannot start the video window", status);392 ErrorAlert(B_TRANSLATE("Cannot start the video window"), status); 376 393 return status; 377 394 } 378 395 … … 436 453 BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), "menu bar"); 437 454 438 455 BMenuItem* menuItem; 439 BMenu* menu = new BMenu( "File");456 BMenu* menu = new BMenu(B_TRANSLATE("File")); 440 457 441 menuItem = new BMenuItem("Video settings", new BMessage(msg_video), 'P'); 458 menuItem = new BMenuItem(B_TRANSLATE("Video settings"), 459 new BMessage(msg_video), 'P'); 442 460 menuItem->SetTarget(be_app); 443 461 menu->AddItem(menuItem); 444 462 445 463 menu->AddSeparatorItem(); 446 464 447 menuItem = new BMenuItem("Start video", new BMessage(msg_start), 'A'); 465 menuItem = new BMenuItem(B_TRANSLATE("Start video"), 466 new BMessage(msg_start), 'A'); 448 467 menuItem->SetTarget(be_app); 449 468 menu->AddItem(menuItem); 450 469 451 menuItem = new BMenuItem("Stop video", new BMessage(msg_stop), 'O'); 470 menuItem = new BMenuItem(B_TRANSLATE("Stop video"), 471 new BMessage(msg_stop), 'O'); 452 472 menuItem->SetTarget(be_app); 453 473 menu->AddItem(menuItem); 454 474 455 475 menu->AddSeparatorItem(); 456 476 457 menuItem = new BMenuItem( "About Codycam" B_UTF8_ELLIPSIS,477 menuItem = new BMenuItem(B_TRANSLATE("About Codycam" B_UTF8_ELLIPSIS), 458 478 new BMessage(msg_about), 'B'); 459 479 menuItem->SetTarget(be_app); 460 480 menu->AddItem(menuItem); 461 481 462 482 menu->AddSeparatorItem(); 463 483 464 menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'); 484 menuItem = new BMenuItem(B_TRANSLATE("Quit"), 485 new BMessage(B_QUIT_REQUESTED), 'Q'); 465 486 menuItem->SetTarget(be_app); 466 487 menu->AddItem(menuItem); 467 488 468 489 menuBar->AddItem(menu); 469 490 470 491 /* give it a gray background view */ 471 fView = new BView( "Background View", B_WILL_DRAW);492 fView = new BView(B_TRANSLATE("Background View"), B_WILL_DRAW); 472 493 fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 473 494 474 495 /* add some controls */ … … 659 680 660 681 // Capture controls 661 682 fCaptureSetupBox = new BBox("Capture Controls", B_WILL_DRAW); 662 fCaptureSetupBox->SetLabel( "Capture controls");683 fCaptureSetupBox->SetLabel(B_TRANSLATE("Capture controls")); 663 684 664 685 BGridLayout *controlsLayout = new BGridLayout(kXBuffer, 0); 665 686 controlsLayout->SetInsets(10, 15, 5, 5); 666 687 fCaptureSetupBox->SetLayout(controlsLayout); 667 688 668 fFileName = new BTextControl("File Name", "File name:",689 fFileName = new BTextControl("File Name", B_TRANSLATE("File name:"), 669 690 fFilenameSetting->Value(), new BMessage(msg_filename)); 670 691 fFileName->SetTarget(BMessenger(NULL, this)); 671 692 672 fImageFormatMenu = new BPopUpMenu( "Image Format Menu");693 fImageFormatMenu = new BPopUpMenu(B_TRANSLATE("Image Format Menu")); 673 694 AddTranslationItems(fImageFormatMenu, B_TRANSLATOR_BITMAP); 674 695 fImageFormatMenu->SetTargetForItems(this); 675 696 … … 682 703 else 683 704 fImageFormatMenu->ItemAt(0)->SetMarked(true); 684 705 685 fImageFormatSelector = new BMenuField("Format", "Format:",706 fImageFormatSelector = new BMenuField("Format", B_TRANSLATE("Format:"), 686 707 fImageFormatMenu, NULL); 687 708 688 fCaptureRateMenu = new BPopUpMenu( "Capture Rate Menu");689 fCaptureRateMenu->AddItem(new BMenuItem( "Every 15 seconds",709 fCaptureRateMenu = new BPopUpMenu(B_TRANSLATE("Capture Rate Menu")); 710 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[0], 690 711 new BMessage(msg_rate_15s))); 691 fCaptureRateMenu->AddItem(new BMenuItem( "Every 30 seconds",712 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[1], 692 713 new BMessage(msg_rate_30s))); 693 fCaptureRateMenu->AddItem(new BMenuItem( "Every minute",714 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[2], 694 715 new BMessage(msg_rate_1m))); 695 fCaptureRateMenu->AddItem(new BMenuItem( "Every 5 minutes",716 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[3], 696 717 new BMessage(msg_rate_5m))); 697 fCaptureRateMenu->AddItem(new BMenuItem( "Every 10 minutes",718 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[4], 698 719 new BMessage(msg_rate_10m))); 699 fCaptureRateMenu->AddItem(new BMenuItem( "Every 15 minutes",720 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[5], 700 721 new BMessage(msg_rate_15m))); 701 fCaptureRateMenu->AddItem(new BMenuItem( "Every 30 minutes",722 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[6], 702 723 new BMessage(msg_rate_30m))); 703 fCaptureRateMenu->AddItem(new BMenuItem( "Every hour",724 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[7], 704 725 new BMessage(msg_rate_1h))); 705 fCaptureRateMenu->AddItem(new BMenuItem( "Every 2 hours",726 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[8], 706 727 new BMessage(msg_rate_2h))); 707 fCaptureRateMenu->AddItem(new BMenuItem( "Every 4 hours",728 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[9], 708 729 new BMessage(msg_rate_4h))); 709 fCaptureRateMenu->AddItem(new BMenuItem( "Every 8 hours",730 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[10], 710 731 new BMessage(msg_rate_8h))); 711 fCaptureRateMenu->AddItem(new BMenuItem( "Every 24 hours",732 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[11], 712 733 new BMessage(msg_rate_24h))); 713 fCaptureRateMenu->AddItem(new BMenuItem( "Never",734 fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[12], 714 735 new BMessage(msg_rate_never))); 715 736 fCaptureRateMenu->SetTargetForItems(this); 716 737 fCaptureRateMenu->FindItem(fCaptureRateSetting->Value())->SetMarked(true); 717 fCaptureRateSelector = new BMenuField("Rate", "Rate:",738 fCaptureRateSelector = new BMenuField("Rate", B_TRANSLATE("Rate:"), 718 739 fCaptureRateMenu, NULL); 719 740 720 741 controlsLayout->AddItem(fFileName->CreateLabelLayoutItem(), 0, 0); 721 742 controlsLayout->AddItem(fFileName->CreateTextViewLayoutItem(), 1, 0); 722 controlsLayout->AddItem(fImageFormatSelector->CreateLabelLayoutItem(), 0, 1); 723 controlsLayout->AddItem(fImageFormatSelector->CreateMenuBarLayoutItem(), 1, 1); 724 controlsLayout->AddItem(fCaptureRateSelector->CreateLabelLayoutItem(), 0, 2); 725 controlsLayout->AddItem(fCaptureRateSelector->CreateMenuBarLayoutItem(), 1, 2); 743 controlsLayout->AddItem(fImageFormatSelector->CreateLabelLayoutItem(), 0, 744 1); 745 controlsLayout->AddItem(fImageFormatSelector->CreateMenuBarLayoutItem(), 1, 746 1); 747 controlsLayout->AddItem(fCaptureRateSelector->CreateLabelLayoutItem(), 0, 748 2); 749 controlsLayout->AddItem(fCaptureRateSelector->CreateMenuBarLayoutItem(), 1, 750 2); 726 751 controlsLayout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, 3, 2); 727 752 728 753 // FTP setup box 729 fFtpSetupBox = new BBox( "FTP Setup", B_WILL_DRAW);754 fFtpSetupBox = new BBox(B_TRANSLATE("FTP Setup"), B_WILL_DRAW); 730 755 731 fUploadClientMenu = new BPopUpMenu( "Send to" B_UTF8_ELLIPSIS);756 fUploadClientMenu = new BPopUpMenu(B_TRANSLATE("Send to" B_UTF8_ELLIPSIS)); 732 757 for (int i = 0; kUploadClient[i]; i++) { 733 758 BMessage *m = new BMessage(msg_upl_client); 734 759 m->AddInt32("client", i); … … 739 764 fUploadClientSelector = new BMenuField("UploadClient", NULL, 740 765 fUploadClientMenu, NULL); 741 766 742 fFtpSetupBox->SetLabel( "Output");767 fFtpSetupBox->SetLabel(B_TRANSLATE("Output")); 743 768 // this doesn't work with the layout manager 744 769 // fFtpSetupBox->SetLabel(fUploadClientSelector); 745 fUploadClientSelector->SetLabel( "Type:");770 fUploadClientSelector->SetLabel(B_TRANSLATE("Type:")); 746 771 747 772 BGridLayout *ftpLayout = new BGridLayout(kXBuffer, 0); 748 773 ftpLayout->SetInsets(10, 15, 5, 5); 749 774 fFtpSetupBox->SetLayout(ftpLayout); 750 775 751 fServerName = new BTextControl("Server", "Server:",776 fServerName = new BTextControl("Server", B_TRANSLATE("Server:"), 752 777 fServerSetting->Value(), new BMessage(msg_server)); 753 778 fServerName->SetTarget(this); 754 779 755 fLoginId = new BTextControl("Login", "Login:",780 fLoginId = new BTextControl("Login", B_TRANSLATE("Login:"), 756 781 fLoginSetting->Value(), new BMessage(msg_login)); 757 782 fLoginId->SetTarget(this); 758 783 759 fPassword = new BTextControl("Password", "Password:",784 fPassword = new BTextControl("Password", B_TRANSLATE("Password:"), 760 785 fPasswordSetting->Value(), new BMessage(msg_password)); 761 786 fPassword->SetTarget(this); 762 787 fPassword->TextView()->HideTyping(true); 763 788 // BeOS HideTyping() seems broken, it empties the text 764 789 fPassword->SetText(fPasswordSetting->Value()); 765 790 766 fDirectory = new BTextControl("Directory", "Directory:",791 fDirectory = new BTextControl("Directory", B_TRANSLATE("Directory:"), 767 792 fDirectorySetting->Value(), new BMessage(msg_directory)); 768 793 fDirectory->SetTarget(this); 769 794 770 fPassiveFtp = new BCheckBox("Passive FTP", "Passive FTP",795 fPassiveFtp = new BCheckBox("Passive FTP", B_TRANSLATE("Passive FTP"), 771 796 new BMessage(msg_passiveftp)); 772 797 fPassiveFtp->SetTarget(this); 773 798 fPassiveFtp->SetValue(fPassiveFtpSetting->Value()); … … 784 809 ftpLayout->AddItem(fDirectory->CreateTextViewLayoutItem(), 1, 4); 785 810 ftpLayout->AddView(fPassiveFtp, 0, 5, 2); 786 811 787 fStatusLine = new BStringView("Status Line", "Waiting" B_UTF8_ELLIPSIS);812 fStatusLine = new BStringView("Status Line", B_TRANSLATE("Waiting" B_UTF8_ELLIPSIS)); 788 813 789 814 BGroupLayout *groupLayout = new BGroupLayout(B_VERTICAL); 790 815 groupLayout->SetInsets(kXBuffer, kYBuffer, kXBuffer, kYBuffer); … … 834 859 fSettings = new Settings(filename, dirname); 835 860 836 861 fServerSetting = new StringValueSetting("Server", "ftp.my.server", 837 "server address expected", "");862 B_TRANSLATE("server address expected"), ""); 838 863 fLoginSetting = new StringValueSetting("Login", "loginID", 839 "login ID expected", "");840 fPasswordSetting = new StringValueSetting("Password", "password",841 "password expected", "");864 B_TRANSLATE("login ID expected"), ""); 865 fPasswordSetting = new StringValueSetting("Password", 866 B_TRANSLATE("password"), B_TRANSLATE("password expected"), ""); 842 867 fDirectorySetting = new StringValueSetting("Directory", "web/images", 843 "destination directory expected", "");868 B_TRANSLATE("destination directory expected"), ""); 844 869 fPassiveFtpSetting = new BooleanValueSetting("PassiveFtp", 1); 845 870 fFilenameSetting = new StringValueSetting("StillImageFilename", 846 "codycam.jpg", "still image filename expected", "");871 "codycam.jpg", B_TRANSLATE("still image filename expected"), ""); 847 872 fImageFormatSettings = new StringValueSetting("ImageFileFormat", 848 "JPEG image", "image file format expected", ""); 873 B_TRANSLATE("JPEG image"), B_TRANSLATE("image file format expected"), 874 ""); 849 875 fCaptureRateSetting = new EnumeratedStringValueSetting("CaptureRate", 850 "Every 5 minutes", kCaptureRate, "capture rate expected",876 kCaptureRate[3], kCaptureRate, B_TRANSLATE("capture rate expected"), 851 877 "unrecognized capture rate specified"); 852 878 fUploadClientSetting = new EnumeratedStringValueSetting("UploadClient", 853 "FTP", kUploadClient, "upload client name expected", 854 "unrecognized upload client specified"); 879 B_TRANSLATE("FTP"), kUploadClient, 880 B_TRANSLATE("upload client name expected"), 881 B_TRANSLATE("unrecognized upload client specified")); 855 882 856 883 fSettings->Add(fServerSetting); 857 884 fSettings->Add(fLoginSetting); … … 900 927 // #pragma mark - 901 928 902 929 903 ControlWindow::ControlWindow(const BRect& frame, BView* controls, media_node node) 904 : BWindow(frame, "Video settings", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) 930 ControlWindow::ControlWindow(const BRect& frame, BView* controls, 931 media_node node) 932 : BWindow(frame, B_TRANSLATE("Video settings"), B_TITLED_WINDOW, 933 B_ASYNCHRONOUS_CONTROLS) 905 934 { 906 935 fView = controls; 907 936 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 17 #define B_TRANSLATE(str) \ 18 be_catalog->GetString((str), TR_CONTEXT) 19 11 20 using std::string; 12 21 13 22 … … 34 43 void SetPassive(bool on); 35 44 36 45 protected: 37 46 private: 47 const char* GetLongReadText() {return B_TRANSLATE("read: %ld\n");}; 48 const char* GetReadText() {return B_TRANSLATE("read: %d\n");}; 49 const char* GetReplyText() {return B_TRANSLATE("reply: '%s'\n");}; 38 50 }; 39 51 40 52 #endif // SFTP_CLIENT_H -
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> … … 23 25 #include <TimeSource.h> 24 26 #include <View.h> 25 27 28 #undef TR_CONTEXT 29 #define TR_CONTEXT "VideoConsumer.cpp" 26 30 27 31 #define M1 ((double)1000000.0) 28 32 #define JITTER 20000 … … 38 42 1, 1, {B_RGB16, 320, 240, 320 * 4, 0, 0}}; 39 43 40 44 41 VideoConsumer::VideoConsumer(const char* name, BView* view, BStringView* statusLine, 45 VideoConsumer::VideoConsumer(const char* name, BView* view, 46 BStringView* statusLine, 42 47 BMediaAddOn* addon, const uint32 internalId) 43 : BMediaNode(name), BMediaEventLooper(), BBufferConsumer(B_MEDIA_RAW_VIDEO), 48 : BMediaNode(name), 49 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(B_TRANSLATE("Locking the window\n")); 90 97 if (fWindow->Lock()) { 91 printf( "Closing the window\n");98 printf(B_TRANSLATE("Closing the window\n")); 92 99 fWindow->Close(); 93 100 fWindow = 0; 94 101 } … … 652 659 { 653 660 BFile* output; 654 661 655 UpdateFtpStatus( "Capturing Image" B_UTF8_ELLIPSIS);662 UpdateFtpStatus(B_TRANSLATE("Capturing Image" B_UTF8_ELLIPSIS)); 656 663 657 664 /* save a local copy of the image in the requested format */ 658 665 output = new BFile(); … … 663 670 if (err == B_OK) { 664 671 err = SetFileType(output, fTranslator, fImageFormat); 665 672 if (err != B_OK) 666 UpdateFtpStatus( "Error setting type of output file");673 UpdateFtpStatus(B_TRANSLATE("Error setting type of output file")); 667 674 } 668 675 else 669 UpdateFtpStatus( "Error writing output file");676 UpdateFtpStatus(B_TRANSLATE("Error writing output file")); 670 677 671 678 input.DetachBitmap(&bitmap); 672 679 output->Unset(); 673 680 delete output; 674 681 return B_OK; 675 682 } else { 676 UpdateFtpStatus( "Error creating output file");683 UpdateFtpStatus(B_TRANSLATE("Error creating output file")); 677 684 return B_ERROR; 678 685 } 679 686 } … … 695 702 case 2: 696 703 return B_OK; 697 704 default: 698 fprintf(stderr, "invalid upload client %ld\n", fUploadClient); 705 fprintf(stderr, B_TRANSLATE("invalid upload client %ld\n"), 706 fUploadClient); 699 707 return EINVAL; 700 708 } 701 709 702 710 ftp->SetPassive(fPassiveFtp); 703 711 // ftp the local file to our web site 704 712 705 UpdateFtpStatus("Logging in" B_UTF8_ELLIPSIS); 706 if (ftp->Connect((string)fServerText, (string)fLoginText, (string)fPasswordText)) { 713 UpdateFtpStatus(B_TRANSLATE("Logging in" B_UTF8_ELLIPSIS)); 714 if (ftp->Connect((string)fServerText, (string)fLoginText, 715 (string)fPasswordText)) { 707 716 // connect to server 708 UpdateFtpStatus( "Connected" B_UTF8_ELLIPSIS);717 UpdateFtpStatus(B_TRANSLATE("Connected" B_UTF8_ELLIPSIS)); 709 718 710 719 if (ftp->ChangeDir((string)fDirectoryText)) { 711 720 // cd to the desired directory 712 UpdateFtpStatus( "Transmitting" B_UTF8_ELLIPSIS);721 UpdateFtpStatus(B_TRANSLATE("Transmitting" B_UTF8_ELLIPSIS)); 713 722 714 723 if (ftp->PutFile((string)filename, (string)"temp")) { 715 724 // send the file to the server … … 717 726 ftp->Chmod((string)"temp", (string)"644"); 718 727 // make it world readable 719 728 720 UpdateFtpStatus( "Renaming" B_UTF8_ELLIPSIS);729 UpdateFtpStatus(B_TRANSLATE("Renaming" B_UTF8_ELLIPSIS)); 721 730 722 731 if (ftp->MoveFile((string)"temp", (string)filename)) { 723 732 // change to the desired name 724 733 uint32 time = real_time_clock(); 725 734 char s[80]; 726 strcpy(s, "Last Capture: ");735 strcpy(s, B_TRANSLATE("Last Capture: ")); 727 736 strcat(s, ctime((const long*)&time)); 728 737 s[strlen(s) - 1] = 0; 729 738 UpdateFtpStatus(s); … … 731 740 return B_OK; 732 741 } 733 742 else 734 UpdateFtpStatus( "Rename failed");743 UpdateFtpStatus(B_TRANSLATE("Rename failed")); 735 744 } 736 745 else 737 UpdateFtpStatus( "File transmission failed");746 UpdateFtpStatus(B_TRANSLATE("File transmission failed")); 738 747 } 739 748 else 740 UpdateFtpStatus("Couldn't find requested directory on server"); 749 UpdateFtpStatus(B_TRANSLATE("Couldn't find requested directory on " 750 "server")); 741 751 } 742 752 else 743 UpdateFtpStatus( "Server login failed");753 UpdateFtpStatus(B_TRANSLATE("Server login failed")); 744 754 745 755 delete ftp; 746 756 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> 16 18 #include <TextControl.h> 17 19 #include <Window.h> 18 20 21 #undef TR_CONTEXT 22 #define TR_CONTEXT "CodyCam" 19 23 24 #define B_TRANSLATE(str) \ 25 be_catalog->GetString((str), TR_CONTEXT) 26 20 27 class BMediaRoster; 21 28 22 29 … … 25 32 26 33 msg_rate_15s = 'r15s', 27 34 msg_rate_30s = 'r30s', 28 msg_rate_1m 29 msg_rate_5m 35 msg_rate_1m = 'r1m ', 36 msg_rate_5m = 'r5m ', 30 37 msg_rate_10m = 'r10m', 31 38 msg_rate_15m = 'r15m', 32 39 msg_rate_30m = 'r30m', 33 msg_rate_1h 34 msg_rate_2h 35 msg_rate_4h 36 msg_rate_8h 40 msg_rate_1h = 'r1h ', 41 msg_rate_2h = 'r2h ', 42 msg_rate_4h = 'r4h ', 43 msg_rate_8h = 'r8h ', 37 44 msg_rate_24h = 'r24h', 38 45 msg_rate_never = 'nevr', 39 46 40 47 msg_translate = 'tran', 41 48 42 49 msg_upl_client = 'ucli', 43 msg_server 44 msg_login 50 msg_server = 'srvr', 51 msg_login = 'lgin', 45 52 msg_password = 'pswd', 46 53 msg_directory = 'drct', 47 54 msg_passiveftp = 'pasv', 48 55 msg_pswrd_text = 'pstx', 49 56 50 msg_start 51 msg_stop 57 msg_start = 'strt', 58 msg_stop = 'stop', 52 59 53 msg_about 54 msg_setup 55 msg_video 60 msg_about = 'abut', 61 msg_setup = 'setp', 62 msg_video = 'vdeo', 56 63 57 64 msg_control_win = 'ctlw' 58 65 }; 59 66 60 67 61 68 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",69 B_TRANSLATE("Every 15 seconds"), 70 B_TRANSLATE("Every 30 seconds"), 71 B_TRANSLATE("Every minute"), 72 B_TRANSLATE("Every 5 minutes"), 73 B_TRANSLATE("Every 10 minutes"), 74 B_TRANSLATE("Every 15 minutes"), 75 B_TRANSLATE("Every 30 minutes"), 76 B_TRANSLATE("Every hour"), 77 B_TRANSLATE("Every 2 hours"), 78 B_TRANSLATE("Every 4 hours"), 79 B_TRANSLATE("Every 8 hours"), 80 B_TRANSLATE("Every 24 hours"), 81 B_TRANSLATE("Never"), 75 82 0 76 83 }; 77 84 78 85 79 86 const char* kUploadClient[] = { 80 "FTP",81 "SFTP",82 "Local",87 B_TRANSLATE("FTP"), 88 B_TRANSLATE("SFTP"), 89 B_TRANSLATE("Local"), 83 90 0 84 91 }; 85 92 … … 106 113 BWindow* fWindow; 107 114 port_id fPort; 108 115 BWindow* fVideoControlWindow; 116 BCatalog fAppCatalog; 109 117 }; 110 118 111 119 -
src/apps/codycam/Jamfile
11 11 Settings.cpp 12 12 SettingsHandler.cpp 13 13 VideoConsumer.cpp 14 : be media translation $(TARGET_NETAPI_LIB) $(TARGET_LIBSTDC++) 14 : be locale media translation liblocale.so $(TARGET_NETAPI_LIB) 15 $(TARGET_LIBSTDC++) 15 16 : CodyCam.rdef 16 17 ; 17 18 -
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 12 #define B_TRANSLATE(str) \ 13 be_catalog->GetString((str), TR_CONTEXT) 14 6 15 FtpClient::FtpClient() 7 16 : FileUploadClient(), 8 17 fState(0), … … 373 382 374 383 if (path.length() == 0) 375 384 cmd += '/'; 376 printf( "cmd: '%s'\n", cmd.c_str());385 printf(B_TRANSLATE("cmd: '%s'\n"), cmd.c_str()); 377 386 if (_SendRequest(cmd) == true) { 378 387 if (_GetReply(replyString, code, codeType) == true) { 379 printf( "reply: %d, %d\n", code, codeType);388 printf(B_TRANSLATE("reply: %d, %d\n"), code, codeType); 380 389 if (codeType == 2) 381 390 rc = true; 382 391 } … … 424 433 425 434 if (fControl != 0) { 426 435 if (cmd.find("PASS") != string::npos) 427 printf( "PASS <suppressed> (real password sent)\n");436 printf(B_TRANSLATE("PASS <suppressed> (real password sent)\n")); 428 437 else 429 438 printf("%s\n", ccmd.c_str()); 430 439 … … 540 549 } 541 550 542 551 if (!rc && outCode != 421) { 543 outString += "Remote host has closed the connection.\n";552 outString += B_TRANSLATE("Remote host has closed the connection.\n"); 544 553 outCode = 421; 545 554 } 546 555