// slot void mail_listview::refresh(mail_id_t id) { DBG_PRINTF(8, "refresh id=%d", id); mail_msg* msg=find(id); if (msg) { msg->refresh(); // get latest status from database update_msg(msg); } }
/* Visually reflect the new status and priority of the message whose mail_id is 'id'. TODO: see if the propagate_status call shouldn't be moved to msg_list_window instead */ void mail_listview::force_msg_status(mail_id_t id, uint status, int priority) { DBG_PRINTF(8, "force_msg_status(mail_id=" MAIL_ID_FMT_STRING ")", id); mail_msg* pm=find(id); if (pm) { pm->set_status(status); pm->set_priority(priority); update_msg(pm); if (m_msg_window) m_msg_window->propagate_status(pm); } }
static void main_window_load(Window *window) { // Create time TextLayer // 5,52,139,50 s_time_layer = text_layer_create(GRect(0, 0, 145, 68)); s_msg_layer = text_layer_create(GRect(10,100,145,56)); // 5,68,145,80 s_bottom_layer = text_layer_create(GRect(0,69,145,16)); // 0,136,145,60 text_layer_set_background_color(s_time_layer, GColorBlack); text_layer_set_text_color(s_time_layer, GColorWhite); text_layer_set_text(s_time_layer, "00:00"); text_layer_set_background_color(s_msg_layer, GColorWhite); text_layer_set_text_color(s_msg_layer, GColorBlack); text_layer_set_text(s_msg_layer,s_msg); text_layer_set_background_color(s_bottom_layer, GColorBlack); text_layer_set_text_color(s_bottom_layer,GColorWhite); text_layer_set_text(s_bottom_layer,"Mushy"); //Create GFont s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CALC_60)); s_msg_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DINO_48)); //Apply to TextLayer text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); text_layer_set_font(s_msg_layer, s_msg_font); text_layer_set_text_alignment(s_msg_layer, GTextAlignmentCenter); // Use built in font for lower layers text_layer_set_font(s_bottom_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(s_bottom_layer,GTextAlignmentCenter); // Add it as a child layer to the Window's root layer layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_msg_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_bottom_layer)); // Make sure the time is displayed from the start update_msg(); update_time(); }
int main(int argc, char **argv) { int sock; struct sockaddr_in addr; if (argc != 2) usage(); cmd = argv[1]; daemonize(); if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) err(EXIT_FAILURE, "socket()"); memset(&addr, 0, sizeof(addr)); addr.sin_port = htons(QOTD_PORT); if (bind(sock, (struct sockaddr*)&addr, sizeof(addr)) == -1) err(EXIT_FAILURE, "bind()"); if (listen(sock, SOMAXCONN) == -1) err(EXIT_FAILURE, "listen()"); for (;;) { int client_sock = accept(sock, 0, 0); if (client_sock == -1) err(EXIT_FAILURE, "accept()"); update_msg(); write_all(client_sock, actual_msg, strlen(actual_msg)); if (close(client_sock) == -1) err(EXIT_FAILURE, "close()"); } close(sock); return 0; }
void BlockerApp::RefsReceived(BMessage *msg) { entry_ref ref; BNode node; attr_info info; IM::Manager man; for (int32 i = 0; msg->FindRef("refs", i, &ref ) == B_OK; i++ ) { node = BNode(&ref); char *type = ReadAttribute(node, "BEOS:TYPE"); if (strcmp(type, "application/x-person") == 0) { IM::Contact contact(ref); char status[256]; if (contact.GetStatus(status, sizeof(status)) != B_OK ) status[0] = '\0'; if (strcmp(status, BLOCKED_TEXT) == 0) { // already blocked, unblocked contact.SetStatus(OFFLINE_TEXT); BMessage update_msg(IM::UPDATE_CONTACT_STATUS); update_msg.AddRef("contact", &ref); man.SendMessage(&update_msg); } else { if (contact.SetStatus(BLOCKED_TEXT) != B_OK) { LOG("im_blocker", liHigh, "Error setting contact status"); }; }; }; free(type); }; BMessenger(this).SendMessage(B_QUIT_REQUESTED); };
void Object::update_points(point_cloud const& pc) { points_ = pc; update_msg(); }
void ChatWindow::MessageReceived( BMessage * msg ) { switch ( msg->what ) { case IM::SETTINGS_UPDATED: { if (msg->FindString("people_handler", &fPeopleHandler) != B_OK) { fPeopleHandler = kDefaultPeopleHandler; }; RebuildDisplay(); } break; case IM::USER_STOPPED_TYPING: { BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what",IM::USER_STOPPED_TYPING); im_msg.AddRef("contact",&fEntry); fMan->SendMessage(&im_msg); stopSelfTypingTimer(); } break; case IM::USER_STARTED_TYPING: { BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what", IM::USER_STARTED_TYPING); im_msg.AddRef("contact", &fEntry); fMan->SendMessage(&im_msg); startSelfTypingTimer(); } break; case IM::DESKBAR_ICON_CLICKED: { // deskbar icon clicked, move to current workspace and activate SetWorkspaces( 1 << current_workspace() ); Activate(); } break; case IM::ERROR: case IM::MESSAGE: { entry_ref contact; if ( msg->FindRef("contact",&contact) != B_OK ) return; if ( contact != fEntry ) // message not for us, skip it. return; int32 im_what=IM::ERROR; if ( msg->FindInt32("im_what",&im_what) != B_OK ) im_what = IM::ERROR; // int32 old_sel_start, old_sel_end; char timestr[10]; time_t now = time(NULL); strftime(timestr, sizeof(timestr),"[%H:%M]: ", localtime(&now) ); switch ( im_what ) { case IM::STATUS_CHANGED: { // This means we're rebuilding menus we don't rally need to rebuild.. BuildProtocolMenu(); } break; case IM::MESSAGE_SENT: { fText->Append(timestr, C_TIMESTAMP, C_TIMESTAMP, F_TIMESTAMP); BString message; msg->FindString("message", &message); if (message.Compare("/me ", 4) == 0) { fText->Append(_T("* You "), C_ACTION, C_ACTION, F_ACTION); message.Remove(0, 4); fText->Append(message.String(), C_ACTION, C_ACTION, F_ACTION); } else { fText->Append(_T("You say: "), C_OWNNICK, C_OWNNICK, F_TEXT); //fText->Append(msg->FindString("message"), C_TEXT, C_TEXT, F_TEXT); emoticor->AddText(fText,msg->FindString("message"), C_TEXT, F_TEXT,C_TEXT,F_EMOTICON); //by xeD } fText->Append("\n", C_TEXT, C_TEXT, F_TEXT); fText->ScrollToSelection(); } break; case IM::ERROR: { BMessage error; msg->FindMessage("message", &error); int32 error_what = -1; error.FindInt32("im_what", &error_what ); if ( error_what != IM::USER_STARTED_TYPING && error_what != IM::USER_STOPPED_TYPING ) { // ignore messages du to typing fText->Append(timestr, C_TIMESTAMP, C_TIMESTAMP, F_TIMESTAMP); fText->Append("Error: ", C_TEXT, C_TEXT, F_TEXT); fText->Append(msg->FindString("error"), C_TEXT, C_TEXT, F_TEXT); fText->Append("\n", C_TEXT, C_TEXT, F_TEXT); if (!IsActive()) startNotify(); } } break; case IM::MESSAGE_RECEIVED: { if ( msg->FindString("message") == NULL ) { // no message to display, probably opened by user return; } fText->Append(timestr, C_TIMESTAMP, C_TIMESTAMP, F_TIMESTAMP); BString protocol = msg->FindString("protocol"); BString message = msg->FindString("message"); if (protocol.Length() > 0) { fName.ReplaceAll("$protocol$",protocol.String()); } else { fName.ReplaceAll("$protocol$"," "); }; if (message.Compare("/me ", 4) == 0) { fText->Append("* ", C_ACTION, C_ACTION, F_ACTION); fText->Append(fName.String(), C_ACTION, C_ACTION, F_ACTION); fText->Append(" ", C_ACTION, C_ACTION, F_ACTION); message.Remove(0, 4); fText->Append(message.String(), C_ACTION, C_ACTION, F_ACTION); } else { fText->Append(fName.String(), C_OTHERNICK, C_OTHERNICK, F_TEXT); fText->Append(": ", C_OTHERNICK, C_OTHERNICK, F_TEXT); emoticor->AddText(fText,msg->FindString("message"), C_TEXT, F_TEXT,C_TEXT,F_EMOTICON); //by xeD } fText->Append("\n", C_TEXT, C_TEXT, F_TEXT); fText->ScrollToSelection(); if (!IsActive()) startNotify(); stopTypingTimer(); } break; case IM::CONTACT_STARTED_TYPING: { startTypingTimer(); } break; case IM::CONTACT_STOPPED_TYPING: { stopTypingTimer(); } break; } fText->ScrollToSelection(); } break; case SEND_MESSAGE: { if (fInput->TextLength() == 0) return; BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what",IM::SEND_MESSAGE); im_msg.AddRef("contact",&fEntry); im_msg.AddString("message", fInput->Text() ); BMenu *menu = fProtocolMenu->Menu(); if (menu) { IconMenuItem *item = dynamic_cast<IconMenuItem*>(menu->FindMarked()); if ( item ) { BString connection = item->Extra(); if (connection.Length() > 0) { IM::Connection conn(connection.String()); im_msg.AddString("protocol", conn.Protocol()); im_msg.AddString("id", conn.ID()); } } }; if ( fMan->SendMessage(&im_msg) == B_OK ) { fInput->SetText(""); } else { LOG("im_emoclient", liHigh, "Error sending message to im_server"); fText->Append(_T("Error: im_server not running, can't send message\n"), C_TEXT, C_TEXT, F_TEXT); fText->ScrollToSelection(); }; } break; case SHOW_INFO: { BMessage open_msg(B_REFS_RECEIVED); open_msg.AddRef("refs", &fEntry); be_roster->Launch(fPeopleHandler.String(), &open_msg); } break; case VIEW_LOG: { BMessage open(B_REFS_RECEIVED); open.AddRef("refs", &fEntry); be_roster->Launch("application/x-vnd.BeClan.im_binlog_viewer", &open); } break; case VIEW_WEBPAGE: { entry_ref htmlRef; be_roster->FindApp("application/x-vnd.Be.URL.http", &htmlRef); BPath htmlPath(&htmlRef); BMessage argv(B_ARGV_RECEIVED); argv.AddString("argv", htmlPath.Path()); int32 length = -1; char *url = ReadAttribute(BNode(&fEntry), "META:url", &length); if ((url != NULL) && (length > 1)) { url = (char *)realloc(url, (length + 1) * sizeof(char)); url[length] = '\0'; argv.AddString("argv", url); argv.AddInt32("argc", 2); be_roster->Launch(&htmlRef, &argv); } else { LOG("im_emoclient", liMedium, "Contact had no homepage"); }; if (url) free(url); } break; case VIEW_EMOTICONS: { //find emoticon button BView* button = FindView("Emoticons"); BRect buttonBounds = button->Bounds(); //move emoticon window to just below the button BPoint emotLeftBottom = button->ConvertToScreen(buttonBounds.LeftBottom()); popup->SetTargetForItems(this); popup->Go(emotLeftBottom,true,true); } break; case ADD_EMOTICON: { int32 index=msg->FindInt32("index"); BString txt; emoticor->config->menu.FindString("face",index,&txt); txt << " "; fInput->Insert(txt.String()); } break; case EMAIL: { BMessage open_msg(B_REFS_RECEIVED); open_msg.AddRef("refs", &fEntry); // "application/x-vnd.Be-MAIL" be_roster->Launch("text/x-email", &open_msg ); } break; case BLOCK: { IM::Contact contact(fEntry); char status[256]; if ( contact.GetStatus( status, sizeof(status) ) != B_OK ) status[0] = 0; if ( strcmp(status, BLOCKED_TEXT) == 0 ) { // already blocked, unblocked contact.SetStatus(OFFLINE_TEXT); BMessage update_msg(IM::UPDATE_CONTACT_STATUS); update_msg.AddRef("contact", &fEntry); fMan->SendMessage( &update_msg ); } else { if ( contact.SetStatus(BLOCKED_TEXT) != B_OK ) { LOG("im_emoclient", liHigh, "Block: Error setting contact status"); } } } break; case AUTH: { BMessage auth_msg(IM::MESSAGE); auth_msg.AddInt32("im_what", IM::REQUEST_AUTH); auth_msg.AddRef("contact", &fEntry); fMan->SendMessage( &auth_msg ); } break; case B_NODE_MONITOR: { int32 opcode=0; if ( msg->FindInt32("opcode",&opcode) != B_OK ) return; switch ( opcode ) { case B_ENTRY_REMOVED: { // oops. should we close down this window now? // Nah, we'll just disable everything. fInput->MakeEditable(false); fInput->SetViewColor( 198,198,198 ); fInput->Invalidate(); BString title( Title() ); title += " - DELETED!"; SetTitle( title.String() ); } break; case B_ENTRY_MOVED: { entry_ref ref; msg->FindInt32("device", &ref.device); msg->FindInt64("to directory", &ref.directory); ref.set_name( msg->FindString("name") ); fEntry = ref; BEntry entry(&fEntry); if ( !entry.Exists() ) { LOG("im_emoclient", liHigh, "Entry moved: New entry invalid"); } } break; case B_STAT_CHANGED: case B_ATTR_CHANGED: reloadContact(); BuildProtocolMenu(); break; } } break; case kResizeMessage: { BView *view = NULL; msg->FindPointer("view", reinterpret_cast<void**>(&view)); if (dynamic_cast<BScrollView *>(view)) { BPoint point; msg->FindPoint("loc", &point); fResize->MoveTo(fResize->Frame().left, point.y); fTextScroll->ResizeTo(fTextScroll->Frame().Width(), point.y - 1 - fDock->Frame().Height() - 1); fInputScroll->MoveTo(fInputScroll->Frame().left, point.y + 3); fInputScroll->ResizeTo( fInputScroll->Bounds().Width(), fStatusBar->Frame().top - fInputScroll->Frame().top ); fInput->SetTextRect(fInput->Bounds()); fInput->ScrollToSelection(); if ( fSendButton ) { fSendButton->MoveTo(fSendButton->Frame().left, point.y + 3); fSendButton->ResizeTo( fSendButton->Bounds().Width(), fStatusBar->Frame().top - fSendButton->Frame().top ); } }; } break; case B_MOUSE_WHEEL_CHANGED: { fText->MessageReceived(msg); } break; case B_COPY: { int32 start = 0; int32 end = 0; fInput->GetSelection(&start, &end); //printf("%ld - > %ld\n", start, end); } break; case B_SIMPLE_DATA: { entry_ref ref; BNode node; // attr_info info; for (int i = 0; msg->FindRef("refs", i, &ref) == B_OK; i++) { node = BNode(&ref); char *type = ReadAttribute(node, "BEOS:TYPE"); if (strcmp(type, "application/x-person") == 0) { char *name = ReadAttribute(node, "META:name"); char *nickname = ReadAttribute(node, "META:nickname"); char connection[100]; IM::Contact con(ref); con.ConnectionAt(0, connection); if (fInput->TextLength() > 0) fInput->Insert("\n"); fInput->Insert(name); fInput->Insert(" ("); fInput->Insert(nickname); fInput->Insert("): "); fInput->Insert(connection); free(name); free(nickname); }; free(type); }; fInput->ScrollToOffset(fInput->TextLength()); } break; case CLEAR_TYPING: stopTypingTimer(); break; case PROTOCOL_SELECTED: { // a protocol has been selected. Since BMenuField doesn't resize until later, // we have to wait 1000us before actually responding to the change, see below if ( fProtocolHack ) delete fProtocolHack; BMessage protoHack(PROTOCOL_SELECTED2); fProtocolHack = new BMessageRunner( BMessenger(this), &protoHack, 1000, 1 ); } break; case PROTOCOL_SELECTED2: // do what should be done on protocol change fStatusBar->PositionViews(); fInfoView->ResizeTo( fStatusBar->Bounds().Width() - fInfoView->Frame().left, fInfoView->Bounds().Height() ); break; default: BWindow::MessageReceived(msg); } }
static void tick_secs_handler(struct tm *tick_time, TimeUnits units_changed) { update_msg(); }