status_t POP3Protocol::SyncMessages() { bool leaveOnServer; if (fSettings.FindBool("leave_mail_on_server", &leaveOnServer) != B_OK) leaveOnServer = true; // create directory if not exist create_directory(fDestinationDir, 0777); printf("POP3Protocol::SyncMessages()\n"); _ReadManifest(); SetTotalItems(2); ReportProgress(0, 1, "Connect to server..."); status_t error = Connect(); if (error < B_OK) { ResetProgress(); return error; } ReportProgress(0, 1, MDR_DIALECT_CHOICE("Getting UniqueIDs...", "固有のIDを取得中...")); error = _UniqueIDs(); if (error < B_OK) { ResetProgress(); return error; } BStringList toDownload; fManifest.NotHere(fUniqueIDs, &toDownload); int32 numMessages = toDownload.CountItems(); if (numMessages == 0) { CheckForDeletedMessages(); ResetProgress(); return B_OK; } ResetProgress(); SetTotalItems(toDownload.CountItems()); printf("POP3: Messages to download: %i\n", (int)toDownload.CountItems()); for (int32 i = 0; i < toDownload.CountItems(); i++) { const char* uid = toDownload.ItemAt(i); int32 toRetrieve = fUniqueIDs.IndexOf(uid); if (toRetrieve < 0) { // should not happen! error = B_NAME_NOT_FOUND; printf("POP3: uid %s index %i not found in fUniqueIDs!\n", uid, (int)toRetrieve); continue; } BPath path(fDestinationDir); BString fileName = "Downloading file... uid: "; fileName += uid; fileName.ReplaceAll("/", "_SLASH_"); path.Append(fileName); BEntry entry(path.Path()); BFile file(&entry, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); error = file.InitCheck(); if (error != B_OK) { printf("POP3: Can't create file %s\n ", path.Path()); break; } BMailMessageIO mailIO(this, &file, toRetrieve); entry_ref ref; entry.GetRef(&ref); // the ref becomes invalid after renaming the file thus we already // write the status here MarkMessageAsRead(ref, B_UNREAD); int32 size = MessageSize(toRetrieve); if (fFetchBodyLimit < 0 || size <= fFetchBodyLimit) { error = mailIO.Seek(0, SEEK_END); if (error < 0) { printf("POP3: Failed to download body %s\n ", uid); break; } NotifyHeaderFetched(ref, &file); NotifyBodyFetched(ref, &file); if (!leaveOnServer) Delete(toRetrieve); } else { int32 dummy; error = mailIO.ReadAt(0, &dummy, 1); if (error < 0) { printf("POP3: Failed to download header %s\n ", uid); break; } NotifyHeaderFetched(ref, &file); } ReportProgress(0, 1); if (file.WriteAttr("MAIL:unique_id", B_STRING_TYPE, 0, uid, strlen(uid)) < 0) { error = B_ERROR; } file.WriteAttr("MAIL:size", B_INT32_TYPE, 0, &size, sizeof(int32)); // save manifest in case we get disturbed fManifest += uid; _WriteManifest(); } ResetProgress(); CheckForDeletedMessages(); Disconnect(); return error; }
void ConfigWindow::LoadSettings() { Accounts::Delete(); Accounts::Create(fAccountsListView,fConfigView); // load in general settings BMailSettings *settings = new BMailSettings(); status_t status = SetToGeneralSettings(settings); if (status == B_OK) { // adjust own window frame BScreen screen(this); BRect screenFrame(screen.Frame().InsetByCopy(0,5)); BRect frame(settings->ConfigWindowFrame()); if (screenFrame.Contains(frame.LeftTop())) MoveTo(frame.LeftTop()); else // center on screen MoveTo((screenFrame.Width() - frame.Width()) / 2,(screenFrame.Height() - frame.Height()) / 2); } else fprintf(stderr, MDR_DIALECT_CHOICE ( "Error retrieving general settings: %s\n", "一般設定の収得に失敗: %s\n"), strerror(status)); delete settings; }
void ConfigWindow::RevertToLastSettings() { // revert general settings BMailSettings settings; // restore status window look settings.SetStatusWindowLook(settings.StatusWindowLook()); status_t status = SetToGeneralSettings(&settings); if (status != B_OK) { char text[256]; sprintf(text, MDR_DIALECT_CHOICE ("\nThe general settings couldn't be reverted.\n\n" "Error retrieving general settings:\n%s\n", "\n一般設定を戻せませんでした。\n\n一般設定収得エラー:\n%s\n"), strerror(status)); (new BAlert("Error",text,"Ok",NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT))->Go(); } // revert account data if (fAccountsListView->CurrentSelection() != -1) ((CenterContainer *)fConfigView)->DeleteChildren(); Accounts::Delete(); Accounts::Create(fAccountsListView,fConfigView); if (fConfigView->CountChildren() == 0) MakeHowToView(); }
void Account::CreateOutbound() { if (!(fOutbound = NewMailChain())) { (new BAlert( MDR_DIALECT_CHOICE ("E-mail","メール"), MDR_DIALECT_CHOICE ("Could not create outbound chain.","送信チェーンは作成できませんでした。"), MDR_DIALECT_CHOICE ("OK","了解")))->Go(); return; } fOutbound->SetChainDirection(outbound); BPath path,addOnPath; find_directory(B_USER_ADDONS_DIRECTORY,&addOnPath); BMessage msg; entry_ref ref; path = addOnPath; path.Append(kSystemFilterAddOnPath); path.Append(MDR_DIALECT_CHOICE ("Outbox", "送信箱")); if (!BEntry(path.Path()).Exists()) { find_directory(B_BEOS_ADDONS_DIRECTORY,&path); path.Append(kSystemFilterAddOnPath); path.Append(MDR_DIALECT_CHOICE ("Outbox", "送信箱")); } BEntry(path.Path()).GetRef(&ref); fOutbound->AddFilter(msg,ref); path = addOnPath; path.Append(kOutboundProtocolAddOnPath); path.Append("SMTP"); if (!BEntry(path.Path()).Exists()) { find_directory(B_BEOS_ADDONS_DIRECTORY,&path); path.Append(kOutboundProtocolAddOnPath); path.Append("SMTP"); } BEntry(path.Path()).GetRef(&ref); fOutbound->AddFilter(msg,ref); // set already made account settings CopyMetaData(fOutbound,fInbound); }
void NotifyCallback::Callback(status_t result) { parent->callback = NULL; if (num_messages == 0) return; if (strategy & do_beep) system_beep("New E-mail"); if (strategy & alert) { BString text; MDR_DIALECT_CHOICE ( text << "You have " << num_messages << " new message" << ((num_messages != 1) ? "s" : "") << " for " << chainrunner->Chain()->Name() << ".", text << chainrunner->Chain()->Name() << "より\n" << num_messages << " 通のメッセージが届きました"); BAlert *alert = new BAlert(MDR_DIALECT_CHOICE ("New messages","新着メッセージ"), text.String(), "OK", NULL, NULL, B_WIDTH_AS_USUAL); alert->SetFeel(B_NORMAL_WINDOW_FEEL); alert->Go(NULL); } if (strategy & blink_leds) be_app->PostMessage('mblk'); if (strategy & one_central_beep) be_app->PostMessage('mcbp'); if (strategy & big_doozy_alert) { BMessage msg('numg'); msg.AddInt32("num_messages",num_messages); msg.AddString("chain_name",chainrunner->Chain()->Name()); msg.AddInt32("chain_id",chainrunner->Chain()->ID()); be_app->PostMessage(&msg); } if (strategy & log_window) { BString message; message << num_messages << " new message" << ((num_messages != 1) ? "s" : ""); chainrunner->ShowMessage(message.String()); } }
ConfigView::ConfigView() : BView(BRect(0,0,10,10),"notifier_config",B_FOLLOW_LEFT | B_FOLLOW_TOP,0) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // determine font height font_height fontHeight; GetFontHeight(&fontHeight); float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 6; BRect frame(5,2,250,itemHeight + 2); BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING,false,false); const char *notifyMethods[] = { MDR_DIALECT_CHOICE ("Beep","音"), MDR_DIALECT_CHOICE ("Alert","窓(メール毎)"), MDR_DIALECT_CHOICE ("Keyboard LEDs","キーボードLED"), MDR_DIALECT_CHOICE ("Central alert","窓(一括)"), "Central beep","Log window"}; for (int32 i = 0,j = 1;i < 6;i++,j *= 2) menu->AddItem(new BMenuItem(notifyMethods[i],new BMessage(kMsgNotifyMethod))); BMenuField *field = new BMenuField(frame,"notify", MDR_DIALECT_CHOICE ("Method:","方法:"),menu); field->ResizeToPreferred(); field->SetDivider(field->StringWidth( MDR_DIALECT_CHOICE ("Method:","方法:")) + 6); AddChild(field); ResizeToPreferred(); }
void ConfigWindow::MakeHowToView() { BResources *resources = BApplication::AppResources(); if (resources) { size_t length; char *buffer = (char *)resources->FindResource('ICON',101,&length); if (buffer) { BBitmap *bitmap = new BBitmap(BRect(0,0,63,63),B_CMAP8); if (bitmap && bitmap->InitCheck() == B_OK) { // copy and enlarge a 32x32 8-bit bitmap char *bits = (char *)bitmap->Bits(); for (int32 i = 0,j = -64;i < length;i++) { if ((i % 32) == 0) j += 64; char *b = bits + (i << 1) + j; b[0] = b[1] = b[64] = b[65] = buffer[i]; } fConfigView->AddChild(new BitmapView(bitmap)); } else delete bitmap; } } BRect rect = fConfigView->Bounds(); BTextView *text = new BTextView(rect,NULL,rect,B_FOLLOW_NONE,B_WILL_DRAW); text->SetViewColor(fConfigView->Parent()->ViewColor()); text->SetAlignment(B_ALIGN_CENTER); text->SetText( MDR_DIALECT_CHOICE ("\n\nCreate a new account using the \"Add\" button.\n\n" "Delete accounts (or only the inbound/outbound) by using the \"Remove\" button on the selected item.\n\n" "Select an item in the list to edit its configuration.", "\n\nアカウントの新規作成は\"追加\"ボタンを\n使います。" "\n\nアカウント自体またはアカウントの\n送受信設定を削除するには\n項目を選択して\"削除\"ボタンを使います。" "\n\nアカウント内容の変更は、\nマウスで項目をクリックしてください。")); rect = text->Bounds(); text->ResizeTo(rect.Width(),text->TextHeight(0,42)); text->SetTextRect(rect); text->MakeEditable(false); text->MakeSelectable(false); fConfigView->AddChild(text); static_cast<CenterContainer *>(fConfigView)->Layout(); }
Account::Account(BMailChain *inbound,BMailChain *outbound) : fInbound(inbound), fOutbound(outbound), fAccountItem(NULL), fInboundItem(NULL), fOutboundItem(NULL), fFilterItem(NULL) { fSettings = fInbound ? fInbound : fOutbound; BString label; if (fSettings) label << fSettings->Name(); else label << MDR_DIALECT_CHOICE ("Unnamed","名称未定"); fAccountItem = new AccountItem(label.String(),this,ACCOUNT_ITEM); fInboundItem = new AccountItem(MDR_DIALECT_CHOICE (" · Incoming"," - 受信"),this,INBOUND_ITEM); fOutboundItem = new AccountItem(MDR_DIALECT_CHOICE (" · Outgoing"," - 送信"),this,OUTBOUND_ITEM); fFilterItem = new AccountItem(MDR_DIALECT_CHOICE (" · E-mail filters"," - フィルタ"),this,FILTER_ITEM); }
bool TSignatureWindow::Clear() { int32 result; if (IsDirty()) { beep(); result = (new BAlert("", MDR_DIALECT_CHOICE ("Save changes to signature?","変更した署名を保存しますか?"), MDR_DIALECT_CHOICE ("Don't save","保存しない"), MDR_DIALECT_CHOICE ("Cancel","中止"), MDR_DIALECT_CHOICE ("Save","保存する"), B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(); if (result == 1) return false; if (result == 2) Save(); } delete fFile; fFile = NULL; fSigView->fTextView->fDirty = false; return true; }
status_t POP3Protocol::Stat() { runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Getting mailbox size...", "メールボックスのサイズを取得しています...")); if (SendCommand("STAT" CRLF) < B_OK) return B_ERROR; int32 messages,dropSize; if (sscanf(fLog.String(), "+OK %ld %ld", &messages, &dropSize) < 2) return B_ERROR; fNumMessages = messages; fMailDropSize = dropSize; return B_OK; }
status_t POP3Protocol::UniqueIDs() { status_t ret = B_OK; runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Getting UniqueIDs...", "固有のIDを取得中...")); ret = SendCommand("UIDL" CRLF); if (ret != B_OK) return ret; BString result; int32 uid_offset; while (ReceiveLine(result) > 0) { if (result.ByteAt(0) == '.') break; uid_offset = result.FindFirst(' ') + 1; result.Remove(0,uid_offset); unique_ids->AddItem(result.String()); } if (SendCommand("LIST" CRLF) != B_OK) return B_ERROR; int32 b; while (ReceiveLine(result) > 0) { if (result.ByteAt(0) == '.') break; b = result.FindLast(" "); if (b >= 0) b = atol(&(result.String()[b])); else b = 0; fSizes.AddItem((void *)(b)); } return ret; }
ConfigWindow::ConfigWindow() : BWindow(BRect(200.0, 200.0, 640.0, 640.0), "E-mail", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE), fLastSelectedAccount(NULL), fSaveSettings(false) { /*** create controls ***/ BRect rect(Bounds()); BView *top = new BView(rect,NULL,B_FOLLOW_ALL,0); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(top); // determine font height font_height fontHeight; top->GetFontHeight(&fontHeight); int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 5; rect.InsetBy(5,5); rect.bottom -= 11 + height; BTabView *tabView = new BTabView(rect,NULL); BView *view,*generalView; rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4; tabView->AddTab(view = new BView(rect,NULL,B_FOLLOW_ALL,0)); tabView->TabAt(0)->SetLabel(MDR_DIALECT_CHOICE ("Accounts","アカウント")); view->SetViewColor(top->ViewColor()); // accounts listview rect = view->Bounds().InsetByCopy(8,8); rect.right = 140 - B_V_SCROLL_BAR_WIDTH; rect.bottom -= height + 12; fAccountsListView = new AccountsListView(rect); view->AddChild(new BScrollView(NULL,fAccountsListView,B_FOLLOW_ALL,0,false,true)); rect.right += B_V_SCROLL_BAR_WIDTH; rect.top = rect.bottom + 8; rect.bottom = rect.top + height; BRect sizeRect = rect; sizeRect.right = sizeRect.left + 30 + view->StringWidth(MDR_DIALECT_CHOICE ("Add","追加")); view->AddChild(new BButton(sizeRect,NULL,MDR_DIALECT_CHOICE ("Add","追加"), new BMessage(kMsgAddAccount),B_FOLLOW_BOTTOM)); sizeRect.left = sizeRect.right+3; sizeRect.right = sizeRect.left + 30 + view->StringWidth(MDR_DIALECT_CHOICE ("Remove","削除")); view->AddChild(fRemoveButton = new BButton(sizeRect,NULL,MDR_DIALECT_CHOICE ("Remove","削除"), new BMessage(kMsgRemoveAccount),B_FOLLOW_BOTTOM)); // accounts config view rect = view->Bounds(); rect.left = fAccountsListView->Frame().right + B_V_SCROLL_BAR_WIDTH + 16; rect.right -= 10; view->AddChild(fConfigView = new CenterContainer(rect)); MakeHowToView(); // general settings rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4; tabView->AddTab(view = new CenterContainer(rect)); tabView->TabAt(1)->SetLabel(MDR_DIALECT_CHOICE ("General","一般")); rect = view->Bounds().InsetByCopy(8,8); rect.right -= 1; rect.bottom = rect.top + height * 5 + 15; BBox *box = new BBox(rect); box->SetLabel(MDR_DIALECT_CHOICE ("Retrieval Frequency","メールチェック間隔")); view->AddChild(box); rect = box->Bounds().InsetByCopy(8,8); rect.top += 7; rect.bottom = rect.top + height + 5; BRect tile = rect.OffsetByCopy(0,1); int32 labelWidth = (int32)view->StringWidth(MDR_DIALECT_CHOICE ("Check every:","メールチェック間隔:"))+6; tile.right = 80 + labelWidth; fIntervalControl = new BTextControl(tile,"time",MDR_DIALECT_CHOICE ("Check every:","メールチェック間隔:"), NULL,NULL); fIntervalControl->SetDivider(labelWidth); box->AddChild(fIntervalControl); BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING); const char *frequencyStrings[] = { MDR_DIALECT_CHOICE ("Never","チェックしない"), MDR_DIALECT_CHOICE ("Minutes","分毎チェック"), MDR_DIALECT_CHOICE ("Hours","時間毎チェック"), MDR_DIALECT_CHOICE ("Days","日間毎チェック")}; BMenuItem *item; for (int32 i = 0;i < 4;i++) { frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],new BMessage(kMsgIntervalUnitChanged))); if (i == 1) item->SetMarked(true); } tile.left = tile.right + 5; tile.right = rect.right; tile.OffsetBy(0,-1); fIntervalUnitField = new BMenuField(tile,"frequency", B_EMPTY_STRING, frequencyPopUp); fIntervalUnitField->SetDivider(0.0); box->AddChild(fIntervalUnitField); rect.OffsetBy(0,height + 9); rect.bottom -= 2; fPPPActiveCheckBox = new BCheckBox(rect,"ppp active", MDR_DIALECT_CHOICE ("only when PPP is active","PPP接続中時のみ"), NULL); box->AddChild(fPPPActiveCheckBox); rect.OffsetBy(0,height + 9); rect.bottom -= 2; fPPPActiveSendCheckBox = new BCheckBox(rect,"ppp activesend", MDR_DIALECT_CHOICE ("Queue outgoing mail when PPP is inactive","PPP切断時、送信メールを送信箱に入れる"), NULL); box->AddChild(fPPPActiveSendCheckBox); rect = box->Frame(); rect.bottom = rect.top + 4*height + 20; box = new BBox(rect); box->SetLabel(MDR_DIALECT_CHOICE ("Status Window","送受信状況の表示")); view->AddChild(box); BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING); const char *statusModes[] = { MDR_DIALECT_CHOICE ("Never","表示しない"), MDR_DIALECT_CHOICE ("While Sending","送信時"), MDR_DIALECT_CHOICE ("While Sending / Fetching","送受信時"), MDR_DIALECT_CHOICE ("Always","常に表示")}; BMessage *msg; for (int32 i = 0;i < 4;i++) { statusPopUp->AddItem(item = new BMenuItem(statusModes[i],msg = new BMessage(kMsgShowStatusWindowChanged))); msg->AddInt32("ShowStatusWindow",i); if (i == 0) item->SetMarked(true); } rect = box->Bounds().InsetByCopy(8,8); rect.top += 7; rect.bottom = rect.top + height + 5; labelWidth = (int32)view->StringWidth( MDR_DIALECT_CHOICE ("Show Status Window:","ステータスの表示:")) + 8; fStatusModeField = new BMenuField(rect,"show status", MDR_DIALECT_CHOICE ("Show Status Window:","ステータスの表示:"), statusPopUp); fStatusModeField->SetDivider(labelWidth); box->AddChild(fStatusModeField); BPopUpMenu *lookPopUp = new BPopUpMenu(B_EMPTY_STRING); const char *windowLookStrings[] = { MDR_DIALECT_CHOICE ("Normal, With Tab","タブ付通常"), MDR_DIALECT_CHOICE ("Normal, Border Only","ボーダーのみ通常"), MDR_DIALECT_CHOICE ("Floating","フローティング"), MDR_DIALECT_CHOICE ("Thin Border","細いボーダー"), MDR_DIALECT_CHOICE ("No Border","ボーダー無し")}; for (int32 i = 0;i < 5;i++) { lookPopUp->AddItem(item = new BMenuItem(windowLookStrings[i],msg = new BMessage(kMsgStatusLookChanged))); msg->AddInt32("StatusWindowLook",i); if (i == 0) item->SetMarked(true); } rect.OffsetBy(0, height + 6); fStatusLookField = new BMenuField(rect,"status look", MDR_DIALECT_CHOICE ("Window Look:","ウィンドウ外観:"),lookPopUp); fStatusLookField->SetDivider(labelWidth); box->AddChild(fStatusLookField); BPopUpMenu *workspacesPopUp = new BPopUpMenu(B_EMPTY_STRING); workspacesPopUp->AddItem(item = new BMenuItem( MDR_DIALECT_CHOICE ("Current Workspace","使用中ワークスペース"), msg = new BMessage(kMsgStatusWorkspaceChanged))); msg->AddInt32("StatusWindowWorkSpace", 0); workspacesPopUp->AddItem(item = new BMenuItem( MDR_DIALECT_CHOICE ("All Workspaces","全てのワークスペース"), msg = new BMessage(kMsgStatusWorkspaceChanged))); msg->AddInt32("StatusWindowWorkSpace", -1); rect.OffsetBy(0,height + 6); fStatusWorkspaceField = new BMenuField(rect,"status workspace", MDR_DIALECT_CHOICE ("Window visible on:","表示場所:"),workspacesPopUp); fStatusWorkspaceField->SetDivider(labelWidth); box->AddChild(fStatusWorkspaceField); rect = box->Frame(); rect.bottom = rect.top + 3*height + 13; box = new BBox(rect); box->SetLabel(MDR_DIALECT_CHOICE ("Deskbar Icon","デスクバーアイコンリンク")); view->AddChild(box); rect = box->Bounds().InsetByCopy(8,8); rect.top += 7; rect.bottom = rect.top + height + 5; BStringView *stringView = new BStringView(rect,B_EMPTY_STRING, MDR_DIALECT_CHOICE ( "The menu links are links to folders in a real folder like the Be menu.", "デスクバーで表示する項目の設定")); box->AddChild(stringView); stringView->SetAlignment(B_ALIGN_CENTER); stringView->ResizeToPreferred(); // BStringView::ResizeToPreferred() changes the width, so that the // alignment has no effect anymore stringView->ResizeTo(rect.Width(), stringView->Bounds().Height()); rect.left += 100; rect.right -= 100; rect.OffsetBy(0,height + 1); BButton *button = new BButton(rect,B_EMPTY_STRING, MDR_DIALECT_CHOICE ("Configure Menu Links","メニューリンクの設定"), msg = new BMessage(B_REFS_RECEIVED)); box->AddChild(button); button->SetTarget(BMessenger("application/x-vnd.Be-TRAK")); BPath path; find_directory(B_USER_SETTINGS_DIRECTORY, &path); path.Append("Mail/Menu Links"); BEntry entry(path.Path()); if (entry.InitCheck() == B_OK && entry.Exists()) { entry_ref ref; entry.GetRef(&ref); msg->AddRef("refs", &ref); } else button->SetEnabled(false); rect = box->Frame(); rect.bottom = rect.top + 2*height + 6; box = new BBox(rect); box->SetLabel(MDR_DIALECT_CHOICE ("Misc.","その他の設定")); view->AddChild(box); rect = box->Bounds().InsetByCopy(8,8); rect.top += 7; rect.bottom = rect.top + height + 5; fAutoStartCheckBox = new BCheckBox(rect,"start daemon", MDR_DIALECT_CHOICE ("Auto-Start Mail Daemon","Mail Daemonを自動起動"),NULL); box->AddChild(fAutoStartCheckBox); // about page rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4; tabView->AddTab(view = new BView(rect,NULL,B_FOLLOW_ALL,0)); tabView->TabAt(2)->SetLabel(MDR_DIALECT_CHOICE ("About","情報")); view->SetViewColor(top->ViewColor()); AboutTextView *about = new AboutTextView(rect); about->SetViewColor(top->ViewColor()); view->AddChild(about); // save/cancel/revert buttons top->AddChild(tabView); rect = tabView->Frame(); rect.top = rect.bottom + 5; rect.bottom = rect.top + height + 5; BButton *saveButton = new BButton(rect,"save", MDR_DIALECT_CHOICE ("Save","保存"), new BMessage(kMsgSaveSettings)); float w,h; saveButton->GetPreferredSize(&w,&h); saveButton->ResizeTo(w,h); saveButton->MoveTo(rect.right - w, rect.top); top->AddChild(saveButton); BButton *cancelButton = new BButton(rect,"cancel", MDR_DIALECT_CHOICE ("Cancel","中止"), new BMessage(kMsgCancelSettings)); cancelButton->GetPreferredSize(&w,&h); cancelButton->ResizeTo(w,h); #ifdef HAVE_APPLY_BUTTON cancelButton->MoveTo(saveButton->Frame().left - w - 5,rect.top); #else cancelButton->MoveTo(saveButton->Frame().left - w - 20,rect.top); #endif top->AddChild(cancelButton); #ifdef HAVE_APPLY_BUTTON BButton *applyButton = new BButton(rect,"apply", MDR_DIALECT_CHOICE ("Apply","適用"), new BMessage(kMsgApplySettings)); applyButton->GetPreferredSize(&w,&h); applyButton->ResizeTo(w,h); applyButton->MoveTo(cancelButton->Frame().left - w - 20,rect.top); top->AddChild(applyButton); #endif BButton *revertButton = new BButton(rect,"revert", MDR_DIALECT_CHOICE ("Revert","復元"), new BMessage(kMsgRevertSettings)); revertButton->GetPreferredSize(&w,&h); revertButton->ResizeTo(w,h); #ifdef HAVE_APPLY_BUTTON revertButton->MoveTo(applyButton->Frame().left - w - 5,rect.top); #else revertButton->MoveTo(cancelButton->Frame().left - w - 6,rect.top); #endif top->AddChild(revertButton); LoadSettings(); fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected)); }
TSignatureWindow::TSignatureWindow(BRect rect) : BWindow (rect, MDR_DIALECT_CHOICE ("Signatures","署名の編集"), B_TITLED_WINDOW, 0), fFile(NULL) { BMenu *menu; BMenuBar *menu_bar; BMenuItem *item; BRect r = Bounds(); /*** Set up the menus ****/ menu_bar = new BMenuBar(r, "MenuBar"); menu = new BMenu(MDR_DIALECT_CHOICE ("Signature","S) 署名")); menu->AddItem(fNew = new BMenuItem(MDR_DIALECT_CHOICE ("New","N) 新規"), new BMessage(M_NEW), 'N')); fSignature = new TMenu(MDR_DIALECT_CHOICE ("Open","O) 開く"), INDEX_SIGNATURE, M_SIGNATURE); menu->AddItem(new BMenuItem(fSignature)); menu->AddSeparatorItem(); menu->AddItem(fSave = new BMenuItem(MDR_DIALECT_CHOICE ("Save","S) 保存"), new BMessage(M_SAVE), 'S')); menu->AddItem(fDelete = new BMenuItem(MDR_DIALECT_CHOICE ("Delete","T) 削除"), new BMessage(M_DELETE), 'T')); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE ("Close","W) 閉じる"), new BMessage(B_QUIT_REQUESTED), 'W')); menu_bar->AddItem(menu); menu = new BMenu(MDR_DIALECT_CHOICE ("Edit","E) 編集")); menu->AddItem(fUndo = new BMenuItem(MDR_DIALECT_CHOICE ("Undo","Z) やり直し"), new BMessage(B_UNDO), 'Z')); fUndo->SetTarget(NULL, this); menu->AddSeparatorItem(); menu->AddItem(fCut = new BMenuItem(MDR_DIALECT_CHOICE ("Cut","X) 切り取り"), new BMessage(B_CUT), 'X')); fCut->SetTarget(NULL, this); menu->AddItem(fCopy = new BMenuItem(MDR_DIALECT_CHOICE ("Copy","C) コピー"), new BMessage(B_COPY), 'C')); fCopy->SetTarget(NULL, this); menu->AddItem(fPaste = new BMenuItem(MDR_DIALECT_CHOICE ("Paste","V) 貼り付け"), new BMessage(B_PASTE), 'V')); fPaste->SetTarget(NULL, this); menu->AddItem(item = new BMenuItem(MDR_DIALECT_CHOICE ("Select All","A) 全文選択"), new BMessage(M_SELECT), 'A')); item->SetTarget(NULL, this); menu_bar->AddItem(menu); AddChild(menu_bar); /**** Done with the menu set up *****/ /**** Add on the panel, giving it the width and at least one vertical pixel *****/ fSigView = new TSignatureView(BRect(0, menu_bar->Frame().bottom+1, rect.Width(), menu_bar->Frame().bottom+2)); AddChild(fSigView); /* resize the window to the correct height */ fSigView->SetResizingMode(B_FOLLOW_NONE); ResizeTo(rect.Width()-2, fSigView->Frame().bottom-2); fSigView->SetResizingMode(B_FOLLOW_ALL); SetSizeLimits(kSigWidth, RIGHT_BOUNDARY, r.top + 100, RIGHT_BOUNDARY); }
void TSignatureWindow::Save() { char name[B_FILE_NAME_LENGTH]; int32 index = 0; status_t result; BDirectory dir; BEntry entry; BNodeInfo *node; BPath path; if (!fFile) { find_directory(B_USER_SETTINGS_DIRECTORY, &path, true); dir.SetTo(path.Path()); if (dir.FindEntry("bemail", &entry) == B_NO_ERROR) dir.SetTo(&entry); else dir.CreateDirectory("bemail", &dir); if (dir.InitCheck() != B_NO_ERROR) goto err_exit; if (dir.FindEntry("signatures", &entry) == B_NO_ERROR) dir.SetTo(&entry); else dir.CreateDirectory("signatures", &dir); if (dir.InitCheck() != B_NO_ERROR) goto err_exit; fFile = new BFile(); while(true) { sprintf(name, "signature_%ld", index++); if ((result = dir.CreateFile(name, fFile, true)) == B_NO_ERROR) break; if (result != EEXIST) goto err_exit; } dir.FindEntry(name, &fEntry); node = new BNodeInfo(fFile); node->SetType("text/plain"); delete node; } fSigView->fTextView->fDirty = false; fFile->Seek(0, 0); fFile->Write(fSigView->fTextView->Text(), fSigView->fTextView->TextLength()); fFile->SetSize(fFile->Position()); fFile->WriteAttr(INDEX_SIGNATURE, B_STRING_TYPE, 0, fSigView->fName->Text(), strlen(fSigView->fName->Text()) + 1); return; err_exit: beep(); (new BAlert("", MDR_DIALECT_CHOICE ( "An error occurred trying to save this signature.", "署名を保存しようとした時にエラーが発生しました。"), MDR_DIALECT_CHOICE ("Sorry","了解")))->Go(); }
status_t POP3Protocol::Open(const char *server, int port, int) { runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Connecting to POP3 server...", "POP3サーバに接続しています...")); if (port <= 0) { #ifdef USE_SSL port = fUseSSL ? 995 : 110; #else port = 110; #endif } fLog = ""; // Prime the error message BString error_msg; error_msg << MDR_DIALECT_CHOICE("Error while connecting to server ", "サーバに接続中にエラーが発生しました ") << server; if (port != 110) error_msg << ":" << port; uint32 hostIP = inet_addr(server); // first see if we can parse it as a numeric address if (hostIP == 0 || hostIP == ~0UL) { struct hostent * he = gethostbyname(server); hostIP = he ? *((uint32*)he->h_addr) : 0; } if (hostIP == 0) { error_msg << MDR_DIALECT_CHOICE(": Connection refused or host not found", ": :接続が拒否されたかサーバーが見つかりません"); runner->ShowError(error_msg.String()); return B_NAME_NOT_FOUND; } #ifndef ANTARES_TARGET_PLATFORM_BEOS fSocket = socket(AF_INET, SOCK_STREAM, 0); #else fSocket = socket(AF_INET, 2, 0); #endif if (fSocket >= 0) { struct sockaddr_in saAddr; memset(&saAddr, 0, sizeof(saAddr)); saAddr.sin_family = AF_INET; saAddr.sin_port = htons(port); saAddr.sin_addr.s_addr = hostIP; int result = connect(fSocket, (struct sockaddr *) &saAddr, sizeof(saAddr)); if (result < 0) { #ifndef ANTARES_TARGET_PLATFORM_BEOS close(fSocket); #else closesocket(fSocket); #endif fSocket = -1; error_msg << ": " << strerror(errno); runner->ShowError(error_msg.String()); return errno; } } else { error_msg << ": Could not allocate socket."; runner->ShowError(error_msg.String()); return B_ERROR; } #ifdef USE_SSL if (fUseSSL) { SSL_library_init(); SSL_load_error_strings(); RAND_seed(this,sizeof(POP3Protocol)); /*--- Because we're an add-on loaded at an unpredictable time, all the memory addresses and things contained in ourself are esssentially random. */ fSSLContext = SSL_CTX_new(SSLv23_method()); fSSL = SSL_new(fSSLContext); fSSLBio = BIO_new_socket(fSocket, BIO_NOCLOSE); SSL_set_bio(fSSL, fSSLBio, fSSLBio); if (SSL_connect(fSSL) <= 0) { BString error; error << "Could not connect to POP3 server " << settings->FindString("server"); if (port != 995) error << ":" << port; error << ". (SSL connection error)"; runner->ShowError(error.String()); SSL_CTX_free(fSSLContext); #ifndef ANTARES_TARGET_PLATFORM_BEOS close(fSocket); #else closesocket(fSocket); #endif runner->Stop(true); return B_ERROR; } } #endif BString line; status_t err; #ifndef ANTARES_TARGET_PLATFORM_BEOS err = ReceiveLine(line); #else int32 tries = 200000; // no endless loop here while ((err = ReceiveLine(line)) == 0) { if (tries-- < 0) return B_ERROR; } #endif if (err < 0) { #ifndef ANTARES_TARGET_PLATFORM_BEOS close(fSocket); #else closesocket(fSocket); #endif fSocket = -1; error_msg << ": " << strerror(err); runner->ShowError(error_msg.String()); return B_ERROR; } if (strncmp(line.String(), "+OK", 3) != 0) { if (line.Length() > 0) { error_msg << MDR_DIALECT_CHOICE(". The server said:\n", "サーバのメッセージです\n") << line.String(); } else error_msg << ": No reply.\n"; runner->ShowError(error_msg.String()); return B_ERROR; } fLog = line; return B_OK; }
status_t POP3Protocol::Login(const char *uid, const char *password, int method) { status_t err; BString error_msg; error_msg << MDR_DIALECT_CHOICE("Error while authenticating user ", "ユーザー認証中にエラーが発生しました ") << uid; if (method == 1) { //APOP int32 index = fLog.FindFirst("<"); if(index != B_ERROR) { runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE( "Sending APOP authentication...", "APOP認証情報を送信中...")); int32 end = fLog.FindFirst(">",index); BString timestamp(""); fLog.CopyInto(timestamp, index, end - index + 1); timestamp += password; char md5sum[33]; MD5Digest((unsigned char*)timestamp.String(), md5sum); BString cmd = "APOP "; cmd += uid; cmd += " "; cmd += md5sum; cmd += CRLF; err = SendCommand(cmd.String()); if (err != B_OK) { error_msg << MDR_DIALECT_CHOICE(". The server said:\n", "サーバのメッセージです\n") << fLog; runner->ShowError(error_msg.String()); return err; } return B_OK; } else { error_msg << MDR_DIALECT_CHOICE(": The server does not support APOP.", "サーバはAPOPをサポートしていません"); runner->ShowError(error_msg.String()); return B_NOT_ALLOWED; } } runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Sending username...", "ユーザーID送信中...")); BString cmd = "USER "; cmd += uid; cmd += CRLF; err = SendCommand(cmd.String()); if (err != B_OK) { error_msg << MDR_DIALECT_CHOICE(". The server said:\n", "サーバのメッセージです\n") << fLog; runner->ShowError(error_msg.String()); return err; } runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Sending password...", "パスワード送信中...")); cmd = "PASS "; cmd += password; cmd += CRLF; err = SendCommand(cmd.String()); if (err != B_OK) { error_msg << MDR_DIALECT_CHOICE(". The server said:\n", "サーバのメッセージです\n") << fLog; runner->ShowError(error_msg.String()); return err; } return B_OK; }
#include <string.h> #include <Clipboard.h> #include <InterfaceKit.h> #include <StorageKit.h> #include "Mail.h" #include "Signature.h" #include <MDRLanguage.h> extern BRect signature_window; extern int32 level; extern const char *kUndoStrings[]; extern const char *kRedoStrings[]; const char kNameText[] = MDR_DIALECT_CHOICE ("Title:", "署名の名称:"); const char kSigText[] = MDR_DIALECT_CHOICE ("Signature:", "署名:"); //==================================================================== TSignatureWindow::TSignatureWindow(BRect rect) : BWindow (rect, MDR_DIALECT_CHOICE ("Signatures","署名の編集"), B_TITLED_WINDOW, 0), fFile(NULL) { BMenu *menu; BMenuBar *menu_bar; BMenuItem *item; BRect r = Bounds(); /*** Set up the menus ****/
void TSignatureWindow::MessageReceived(BMessage* msg) { char *sig; char name[B_FILE_NAME_LENGTH]; BFont *font; BTextView *text_view; entry_ref ref; off_t size; switch(msg->what) { case CHANGE_FONT: msg->FindPointer("font", (void **)&font); fSigView->fTextView->SetFontAndColor(font); fSigView->fTextView->Invalidate(fSigView->fTextView->Bounds()); break; case M_NEW: if (Clear()) { fSigView->fName->SetText(""); fSigView->fTextView->SetText(NULL, (int32)0); fSigView->fName->MakeFocus(true); } break; case M_SAVE: Save(); break; case M_DELETE: if (level == L_BEGINNER) { beep(); if (!(new BAlert("",MDR_DIALECT_CHOICE ( "Are you sure you want to delete this signature?", "この署名を削除しますか?"), MDR_DIALECT_CHOICE ("Cancel","取消l"), MDR_DIALECT_CHOICE ("Delete","削除"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go()) break; } if (fFile) { delete fFile; fFile = NULL; fEntry.Remove(); fSigView->fName->SetText(""); fSigView->fTextView->SetText(NULL, (int32)0); fSigView->fName->MakeFocus(true); } break; case M_SIGNATURE: if (Clear()) { msg->FindRef("ref", &ref); fEntry.SetTo(&ref); fFile = new BFile(&ref, O_RDWR); if (fFile->InitCheck() == B_NO_ERROR) { fFile->ReadAttr(INDEX_SIGNATURE, B_STRING_TYPE, 0, name, sizeof(name)); fSigView->fName->SetText(name); fFile->GetSize(&size); sig = (char *)malloc(size); size = fFile->Read(sig, size); fSigView->fTextView->SetText(sig, size); fSigView->fName->MakeFocus(true); text_view = (BTextView *)fSigView->fName->ChildAt(0); text_view->Select(0, text_view->TextLength()); fSigView->fTextView->fDirty = false; } else { fFile = NULL; beep(); (new BAlert("", MDR_DIALECT_CHOICE ( "An error occurred trying to open this signature.", "署名を開く時にエラーが発生しました。"), MDR_DIALECT_CHOICE ("Sorry","了解")))->Go(); } } break; default: BWindow::MessageReceived(msg); } }
BPopUpMenu* DeskbarView::_BuildMenu() { BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE ( "Create new message", "N) 新規メッセージ作成")B_UTF8_ELLIPSIS, new BMessage(MD_OPEN_NEW))); menu->AddSeparatorItem(); BMessenger tracker(kTrackerSignature); BNavMenu* navMenu; BMenuItem* item; BMessage* msg; entry_ref ref; BPath path; find_directory(B_USER_SETTINGS_DIRECTORY, &path); path.Append("Mail/Menu Links"); BDirectory directory; if (_CreateMenuLinks(directory, path)) { int32 count = 0; while (directory.GetNextRef(&ref) == B_OK) { count++; path.SetTo(&ref); // the true here dereferences the symlinks all the way :) BEntry entry(&ref, true); // do we want to use the NavMenu, or just an ordinary BMenuItem? // we are using the NavMenu only for directories and queries bool useNavMenu = false; if (entry.InitCheck() == B_OK) { if (entry.IsDirectory()) useNavMenu = true; else if (entry.IsFile()) { // Files should use the BMenuItem unless they are queries char mimeString[B_MIME_TYPE_LENGTH]; BNode node(&entry); BNodeInfo info(&node); if (info.GetType(mimeString) == B_OK && strcmp(mimeString, "application/x-vnd.Be-query") == 0) useNavMenu = true; } // clobber the existing ref only if the symlink derefernces // completely, otherwise we'll stick with what we have entry.GetRef(&ref); } msg = new BMessage(B_REFS_RECEIVED); msg->AddRef("refs", &ref); if (useNavMenu) { item = new BMenuItem(navMenu = new BNavMenu(path.Leaf(), B_REFS_RECEIVED, tracker), msg); navMenu->SetNavDir(&ref); } else item = new BMenuItem(path.Leaf(), msg); menu->AddItem(item); if(entry.InitCheck() != B_OK) item->SetEnabled(false); } if (count > 0) menu->AddSeparatorItem(); } // Hack for R5's buggy Query Notification #ifdef HAIKU_TARGET_PLATFORM_BEOS menu->AddItem(new BMenuItem( MDR_DIALECT_CHOICE("Refresh New Mail Count", "未読メールカウントを更新"), new BMessage(MD_REFRESH_QUERY))); #endif // The New E-mail query if (fNewMessages > 0) { BString string; MDR_DIALECT_CHOICE( string << fNewMessages << " new message" << (fNewMessages != 1 ? "s" : B_EMPTY_STRING), string << fNewMessages << " 通の未読メッセージ"); _GetNewQueryRef(ref); item = new BMenuItem(navMenu = new BNavMenu(string.String(), B_REFS_RECEIVED, BMessenger(kTrackerSignature)), msg = new BMessage(B_REFS_RECEIVED)); msg->AddRef("refs", &ref); navMenu->SetNavDir(&ref); menu->AddItem(item); } else { menu->AddItem(item = new BMenuItem( MDR_DIALECT_CHOICE ("No new messages","未読メッセージなし"), NULL)); item->SetEnabled(false); } BMailAccounts accounts; if (modifiers() & B_SHIFT_KEY) { BMenu *accountMenu = new BMenu( MDR_DIALECT_CHOICE ("Check for mails only","R) メール受信のみ")); BFont font; menu->GetFont(&font); accountMenu->SetFont(&font); for (int32 i = 0; i < accounts.CountAccounts(); i++) { BMailAccountSettings* account = accounts.AccountAt(i); BMessage* message = new BMessage(MD_CHECK_FOR_MAILS); message->AddInt32("account", account->AccountID()); accountMenu->AddItem(new BMenuItem(account->Name(), message)); } if (accounts.CountAccounts() == 0) { item = new BMenuItem("<no accounts>", NULL); item->SetEnabled(false); accountMenu->AddItem(item); } accountMenu->SetTargetForItems(this); menu->AddItem(new BMenuItem(accountMenu, new BMessage(MD_CHECK_FOR_MAILS))); // Not used: // menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE ( // "Check For Mails Only","メール受信のみ"), new BMessage(MD_CHECK_FOR_MAILS))); menu->AddItem(new BMenuItem( MDR_DIALECT_CHOICE ("Send pending mails", "M) 保留メールを送信"), new BMessage(MD_SEND_MAILS))); } else { menu->AddItem(item = new BMenuItem( MDR_DIALECT_CHOICE ("Check for mail now", "C) メールチェック"), new BMessage(MD_CHECK_SEND_NOW))); if (accounts.CountAccounts() == 0) item->SetEnabled(false); } menu->AddSeparatorItem(); menu->AddItem(new BMenuItem( MDR_DIALECT_CHOICE ("Preferences", "P) メール環境設定") B_UTF8_ELLIPSIS, new BMessage(MD_OPEN_PREFS))); if (modifiers() & B_SHIFT_KEY) { menu->AddItem(new BMenuItem( MDR_DIALECT_CHOICE ("Shutdown mail services", "Q) 終了"), new BMessage(B_QUIT_REQUESTED))); } // Reset Item Targets (only those which aren't already set) for (int32 i = menu->CountItems(); i-- > 0;) { item = menu->ItemAt(i); if (item && (msg = item->Message()) != NULL) { if (msg->what == B_REFS_RECEIVED) item->SetTarget(tracker); else item->SetTarget(this); } } return menu; }
void Account::CreateInbound() { if (!(fInbound = NewMailChain())) { (new BAlert( MDR_DIALECT_CHOICE ("E-mail","メール"), MDR_DIALECT_CHOICE ("Could not create inbound chain.","受信チェーンは作成できませんでした。"), MDR_DIALECT_CHOICE ("OK","了解")))->Go(); return; } fInbound->SetChainDirection(inbound); BPath path,addOnPath; find_directory(B_USER_ADDONS_DIRECTORY,&addOnPath); BMessage msg; entry_ref ref; // Protocol path = addOnPath; path.Append(kInboundProtocolAddOnPath); path.Append("POP3"); if (!BEntry(path.Path()).Exists()) { find_directory(B_BEOS_ADDONS_DIRECTORY,&path); path.Append(kInboundProtocolAddOnPath); path.Append("POP3"); } BEntry(path.Path()).GetRef(&ref); fInbound->AddFilter(msg,ref); // Message Parser path = addOnPath; path.Append(kSystemFilterAddOnPath); path.Append("Message Parser"); if (!BEntry(path.Path()).Exists()) { find_directory(B_BEOS_ADDONS_DIRECTORY,&path); path.Append(kSystemFilterAddOnPath); path.Append("Message Parser"); } BEntry(path.Path()).GetRef(&ref); fInbound->AddFilter(msg,ref); // New Mail Notification path = addOnPath; path.Append(kSystemFilterAddOnPath); path.Append(MDR_DIALECT_CHOICE ("New mail notification", "着信通知方法")); if (!BEntry(path.Path()).Exists()) { find_directory(B_BEOS_ADDONS_DIRECTORY,&path); path.Append(kSystemFilterAddOnPath); path.Append(MDR_DIALECT_CHOICE ("New mail notification", "着信通知方法")); } BEntry(path.Path()).GetRef(&ref); fInbound->AddFilter(msg,ref); // Inbox path = addOnPath; path.Append(kSystemFilterAddOnPath); path.Append(MDR_DIALECT_CHOICE ("Inbox", "受信箱")); if (!BEntry(path.Path()).Exists()) { find_directory(B_BEOS_ADDONS_DIRECTORY,&path); path.Append(kSystemFilterAddOnPath); path.Append(MDR_DIALECT_CHOICE ("Inbox", "受信箱")); } BEntry(path.Path()).GetRef(&ref); fInbound->AddFilter(msg,ref); // set already made account settings CopyMetaData(fInbound,fOutbound); }