BEmailMessage * BEmailMessage::ForwardMessage(bool accountFromMail, bool includeAttachments) { BString header = "------ Forwarded Message: ------\n"; header << "To: " << To() << '\n'; header << "From: " << From() << '\n'; if (CC() != NULL) { // Can use CC rather than "Cc" since display only. header << "CC: " << CC() << '\n'; } header << "Subject: " << Subject() << '\n'; header << "Date: " << Date() << "\n\n"; if (_text_body != NULL) header << _text_body->Text() << '\n'; BEmailMessage *message = new BEmailMessage(); message->SetBodyTextTo(header.String()); // set the subject BString subject = Subject(); if (subject.IFindFirst("fwd") == B_ERROR && subject.IFindFirst("forward") == B_ERROR && subject.FindFirst("FW") == B_ERROR) subject << " (fwd)"; message->SetSubject(subject.String()); if (includeAttachments) { for (int32 i = 0; i < CountComponents(); i++) { BMailComponent *cmpt = GetComponent(i); if (cmpt == _text_body || cmpt == NULL) continue; //---I am ashamed to have the written the code between here and the next comment // ... and you still managed to get it wrong ;-)), axeld. // we should really move this stuff into copy constructors // or something like that BMallocIO io; cmpt->RenderToRFC822(&io); BMailComponent *clone = cmpt->WhatIsThis(); io.Seek(0, SEEK_SET); clone->SetToRFC822(&io, io.BufferLength(), true); message->AddComponent(clone); } } if (accountFromMail) message->SendViaAccountFrom(this); return message; }
ObjectOps& BufferBase(GLuint index, BufferName buffer) { OGLPLUS_GLFUNC(TransformFeedbackBufferBase) (_obj_name(), index, GetGLName(buffer)); OGLPLUS_CHECK( TransformFeedbackBufferBase, ObjectPairError, Subject(buffer).Object(*this).Index(index)); return *this; }
int main () { Subject (); Verb (); Object (); return 0; };
void c_subject::on_buttonBox_accepted() { qDebug() << "hierr" << ui->subname->text(); Subject awesomeNewSubject = Subject(ui->subname->text()); qDebug() << "hierr" << ui->subname->text(); connect( this, SIGNAL(), parentWidget(), SLOT(update()) ); MainWindow* parent = qobject_cast<MainWindow*>(this->parent()); // check parent is not null parent->update(); }
Subject::ListPtr Subject::find(Yb::Session &session, const Yb::Expression &filter, const Yb::Expression &order_by) { Subject::ListPtr lst(new Subject::List()); Yb::ObjectList rows; session.load_collection(rows, Yb::Expression(_T("T_SUBJECT")), filter, order_by); if (rows.size()) { Yb::ObjectList::iterator it = rows.begin(), end = rows.end(); for (; it != end; ++it) lst->push_back(Subject(*it)); } return lst; }
ObjectOps& BufferRange( GLuint index, BufferName buffer, BufferSize offset, BufferSize size) { OGLPLUS_GLFUNC(TransformFeedbackBufferRange) (_obj_name(), index, GetGLName(buffer), GLintptr(offset.Get()), GLsizeiptr(size.Get())); OGLPLUS_CHECK( TransformFeedbackBufferRange, ObjectPairError, Subject(buffer).Object(*this).Index(index)); return *this; }
QList<Subject> LoginManager::getSubjects() { QList<Subject> list; if(db.open()) { QString queryString("SELECT * FROM depth_courses"); QSqlQuery query = db.exec(queryString); while(query.next()) { list.append(Subject(query.value(0).toString(), query.value(1).toString(), query.value(2).toInt(), query.value(4).toInt())); } db.close(); return list; } }
/// Set the vertex buffer for this vertex array attribute DSAVertexArrayAttrib& VertexBuffer( BufferName buffer, GLintptr offset, GLsizei stride ) { OGLPLUS_GLFUNC(VertexArrayVertexBuffer)( _vao, GLuint(_location), GetGLName(buffer), offset, stride ); OGLPLUS_CHECK( VertexArrayVertexBuffer, ObjectPairError, Subject(buffer). Object(VertexArrayName(_vao)) ); return *this; }
/** * @see Data * @see SubData * @throws Error * * @glvoereq{3,1,ARB,copy_buffer} */ static void CopySubData( BufferName readbuffer, BufferName writebuffer, BufferSize readoffset, BufferSize writeoffset, BufferSize size ) { OGLPLUS_GLFUNC(CopyNamedBufferSubData)( GetGLName(readbuffer), GetGLName(writebuffer), GLintptr(readoffset.Get()), GLintptr(writeoffset.Get()), GLsizeiptr(size.Get()) ); OGLPLUS_CHECK( CopyNamedBufferSubData, ObjectPairError, Subject(readbuffer). Object(writebuffer) ); }
Event* Clone() const { return (new InputEvent(Subject())); }
BEmailMessage * BEmailMessage::ReplyMessage(mail_reply_to_mode replyTo, bool accountFromMail, const char *quoteStyle) { BEmailMessage *reply = new BEmailMessage; // Set ReplyTo: if (replyTo == B_MAIL_REPLY_TO_ALL) { reply->SetTo(From()); BList list; get_address_list(list, CC(), extract_address); get_address_list(list, To(), extract_address); // Filter out the sender BMailAccounts accounts; BMailAccountSettings* account = accounts.AccountByID(Account()); BString sender; if (account) sender = account->ReturnAddress(); extract_address(sender); BString cc; for (int32 i = list.CountItems(); i-- > 0;) { char *address = (char *)list.RemoveItem((int32)0); // add everything which is not the sender and not already in the list if (sender.ICompare(address) && cc.FindFirst(address) < 0) { if (cc.Length() > 0) cc << ", "; cc << address; } free(address); } if (cc.Length() > 0) reply->SetCC(cc.String()); } else if (replyTo == B_MAIL_REPLY_TO_SENDER || ReplyTo() == NULL) reply->SetTo(From()); else reply->SetTo(ReplyTo()); // Set special "In-Reply-To:" header (used for threading) const char *messageID = _body ? _body->HeaderField("Message-Id") : NULL; if (messageID != NULL) reply->SetHeaderField("In-Reply-To", messageID); // quote body text reply->SetBodyTextTo(BodyText()); if (quoteStyle) reply->Body()->Quote(quoteStyle); // Set the subject (and add a "Re:" if needed) BString string = Subject(); if (string.ICompare("re:", 3) != 0) string.Prepend("Re: "); reply->SetSubject(string.String()); // set the matching outbound chain if (accountFromMail) reply->SendViaAccountFrom(this); return reply; }
status_t BEmailMessage::RenderTo(BDirectory *dir, BEntry *msg) { time_t currentTime; char numericDateString [40]; struct tm timeFields; BString worker; // Generate a file name for the outgoing message. See also // FolderFilter::ProcessMailMessage which does something similar for // incoming messages. BString name = Subject(); SubjectToThread (name); // Extract the core subject words. if (name.Length() <= 0) name = "No Subject"; if (name[0] == '.') name.Prepend ("_"); // Avoid hidden files, starting with a dot. // Convert the date into a year-month-day fixed digit width format, so that // sorting by file name will give all the messages with the same subject in // order of date. time (¤tTime); localtime_r (¤tTime, &timeFields); sprintf (numericDateString, "%04d%02d%02d%02d%02d%02d", timeFields.tm_year + 1900, timeFields.tm_mon + 1, timeFields.tm_mday, timeFields.tm_hour, timeFields.tm_min, timeFields.tm_sec); name << " " << numericDateString; worker = From(); extract_address_name(worker); name << " " << worker; name.Truncate(222); // reserve space for the uniquer // Get rid of annoying characters which are hard to use in the shell. name.ReplaceAll('/','_'); name.ReplaceAll('\'','_'); name.ReplaceAll('"','_'); name.ReplaceAll('!','_'); name.ReplaceAll('<','_'); name.ReplaceAll('>','_'); while (name.FindFirst(" ") >= 0) // Remove multiple spaces. name.Replace(" " /* Old */, " " /* New */, 1024 /* Count */); int32 uniquer = time(NULL); worker = name; int32 tries = 30; bool exists; while ((exists = dir->Contains(worker.String())) && --tries > 0) { srand(rand()); uniquer += (rand() >> 16) - 16384; worker = name; worker << ' ' << uniquer; } if (exists) printf("could not create mail! (should be: %s)\n", worker.String()); BFile file; status_t status = dir->CreateFile(worker.String(), &file); if (status < B_OK) return status; if (msg != NULL) msg->SetTo(dir,worker.String()); return RenderToRFC822(&file); }
status_t BEmailMessage::RenderToRFC822(BPositionIO *file) { if (_body == NULL) return B_MAIL_INVALID_MAIL; // Do real rendering if (From() == NULL) { // set the "From:" string SendViaAccount(_account_id); } BList recipientList; get_address_list(recipientList, To(), extract_address); get_address_list(recipientList, CC(), extract_address); get_address_list(recipientList, _bcc, extract_address); BString recipients; for (int32 i = recipientList.CountItems(); i-- > 0;) { char *address = (char *)recipientList.RemoveItem((int32)0); recipients << '<' << address << '>'; if (i) recipients << ','; free(address); } // add the date field int32 creationTime = time(NULL); { char date[128]; struct tm tm; localtime_r(&creationTime, &tm); size_t length = strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S", &tm); // GMT offsets are full hours, yes, but you never know :-) snprintf(date + length, sizeof(date) - length, " %+03d%02d", tm.tm_gmtoff / 3600, (tm.tm_gmtoff / 60) % 60); SetHeaderField("Date", date); } // add a message-id // empirical evidence indicates message id must be enclosed in // angle brackets and there must be an "at" symbol in it BString messageID; messageID << "<"; messageID << system_time(); messageID << "-BeMail@"; char host[255]; if (gethostname(host, sizeof(host)) < 0 || !host[0]) strcpy(host, "zoidberg"); messageID << host; messageID << ">"; SetHeaderField("Message-Id", messageID.String()); status_t err = BMailComponent::RenderToRFC822(file); if (err < B_OK) return err; file->Seek(-2, SEEK_CUR); // Remove division between headers err = _body->RenderToRFC822(file); if (err < B_OK) return err; // Set the message file's attributes. Do this after the rest of the file // is filled in, in case the daemon attempts to send it before it is ready // (since the daemon may send it when it sees the status attribute getting // set to "Pending"). if (BFile *attributed = dynamic_cast <BFile *>(file)) { BNodeInfo(attributed).SetType(B_MAIL_TYPE); attributed->WriteAttrString(B_MAIL_ATTR_RECIPIENTS,&recipients); BString attr; attr = To(); attributed->WriteAttrString(B_MAIL_ATTR_TO,&attr); attr = CC(); attributed->WriteAttrString(B_MAIL_ATTR_CC,&attr); attr = Subject(); attributed->WriteAttrString(B_MAIL_ATTR_SUBJECT,&attr); attr = ReplyTo(); attributed->WriteAttrString(B_MAIL_ATTR_REPLY,&attr); attr = From(); attributed->WriteAttrString(B_MAIL_ATTR_FROM,&attr); if (Priority() != 3 /* Normal is 3 */) { sprintf (attr.LockBuffer (40), "%d", Priority()); attr.UnlockBuffer(-1); attributed->WriteAttrString(B_MAIL_ATTR_PRIORITY,&attr); } attr = "Pending"; attributed->WriteAttrString(B_MAIL_ATTR_STATUS, &attr); attr = "1.0"; attributed->WriteAttrString(B_MAIL_ATTR_MIME, &attr); attributed->WriteAttr(B_MAIL_ATTR_ACCOUNT, B_INT32_TYPE, 0, &_account_id, sizeof(int32)); attributed->WriteAttr(B_MAIL_ATTR_WHEN, B_TIME_TYPE, 0, &creationTime, sizeof(int32)); int32 flags = B_MAIL_PENDING | B_MAIL_SAVE; attributed->WriteAttr(B_MAIL_ATTR_FLAGS, B_INT32_TYPE, 0, &flags, sizeof(int32)); attributed->WriteAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0, &_account_id, sizeof(int32)); } return B_OK; }