Example #1
0
	void _SplitNormalizedPath(const BString& path, BString& _directory,
		BString& _name)
	{
		// handle single component (including root dir) cases
		int32 lastSlash = path.FindLast('/');
		if (lastSlash < 0 || path.Length() == 1) {
			_directory = (const char*)NULL;
			_name = path;
			return;
		}

		// handle root dir + one component and multi component cases
		if (lastSlash == 0)
			_directory = "/";
		else
			_directory.SetTo(path, lastSlash);
		_name = path.String() + (lastSlash + 1);
	}
bool
CDDBData::RenameTrack(const int32 &index, const char *newName)
{
	if (!newName) {
		STRACE(("CDDBData::RenameTrack failed - NULL newName\n"));
		return false;
	}

	BString *name = (BString*)fTrackList.ItemAt(index);
	if (name) {
		STRACE(("CDDBData::RenameTrack(%" B_PRId32 ",%s)\n", index, newName));
		name->SetTo(newName);
		return true;
	}

	STRACE(("CDDBData::RenameTrack failed - invalid index\n"));
	return false;
}
status_t
AccelerantHWInterface::GetDriverPath(BString& string)
{
	// TODO: this currently assumes that the accelerant's clone info
	//	is always the path name of its driver (that's the case for
	//	all of our drivers)
	char path[B_PATH_NAME_LENGTH];
	get_accelerant_clone_info getCloneInfo;
	getCloneInfo = (get_accelerant_clone_info)fAccelerantHook(
		B_GET_ACCELERANT_CLONE_INFO, NULL);

	if (getCloneInfo == NULL)
		return B_NOT_SUPPORTED;

	getCloneInfo((void*)path);
	string.SetTo(path);
	return B_OK;
}
Example #4
0
char *FindWindow::CreateFindString(char *pBuffer)
{

	BString bsFind;
	
	bsFind.SetTo("FILENAME CONTAINS \"");
	bsFind.Append(myArtist->Text());
	if (strcmp(mySong->Text(), "") != 0)
	{
		bsFind.Append(" ");
		bsFind.Append(mySong->Text());
	}
	bsFind.Append("\" MAX RESULTS ");
	bsFind.Append(myMax->Text());
	
	pBuffer = (char *)malloc(bsFind.Length()+1);
	strcpy(pBuffer, bsFind.String());
	return (pBuffer);
}
BString
BStatusView::_FullSpeedString()
{
	BString buffer;
	if (fBytesPerSecond != 0.0) {
		char sizeBuffer[128];
		buffer.SetTo(B_TRANSLATE(
			"%SizeProcessed of %TotalSize, %BytesPerSecond/s"));
		buffer.ReplaceFirst("%SizeProcessed",
			string_for_size((double)fSizeProcessed, sizeBuffer,
			sizeof(sizeBuffer)));
		buffer.ReplaceFirst("%TotalSize",
			string_for_size((double)fTotalSize, sizeBuffer,
			sizeof(sizeBuffer)));
		buffer.ReplaceFirst("%BytesPerSecond",
			string_for_size(fBytesPerSecond, sizeBuffer, sizeof(sizeBuffer)));
	}
	return buffer;
}
Example #6
0
char * BeCheckersWindow::File(const char *fileName) {
	char *f;

	BPath p;
	find_directory(B_USER_DIRECTORY, &p);

	BString path;
	path.SetTo(p.Path()).Append("/").Append(APP_SGP);
	create_directory(path.String(), 0777);

	p.SetTo(path.String());

    if(p.Path() != NULL) {
		f = new char[strlen(p.Path()) + strlen(fileName) + 6] = {'\0'};
		sprintf(f, "%s%s%s%s", p.Path(), "/", fileName, APP_XTN);	// Thanks, Charlie.
	}

	return(p.Path() == NULL ? NULL : f);
}
Example #7
0
void
StringEditor::_UpdateText()
{
	BAutolock locker(fEditor);

	size_t viewSize = fEditor.ViewSize();
	// that may need some more memory...
	if ((off_t)viewSize < fEditor.FileSize())
		fEditor.SetViewSize(fEditor.FileSize());

	const char *buffer;
	if (fEditor.GetViewBuffer((const uint8 **)&buffer) == B_OK) {
		fTextView->SetText(buffer);
		fPreviousText.SetTo(buffer);
	}

	// restore old view size
	fEditor.SetViewSize(viewSize);
}
status_t
IntegerValueFormatter::FormatValue(Value* _value, BString& _output)
{
    IntegerValue* value = dynamic_cast<IntegerValue*>(_value);
    if (value == NULL)
        return B_BAD_VALUE;

    // format the value
    integer_format format = fConfig != NULL
                            ? fConfig->IntegerFormat() : INTEGER_FORMAT_DEFAULT;
    char buffer[32];
    if (!IntegerFormatter::FormatValue(value->GetValue(), format,  buffer,
                                       sizeof(buffer))) {
        return B_BAD_VALUE;
    }

    _output.SetTo(buffer);

    return B_OK;
}
/*	isCue
*	checks if selected file is a cue file (checks by file extension)
*	if yes, returns true
*/
bool
ProjectTypeSelector::isCue()
{
	BString *SelectedFile = (BString*)FileList->FirstItem();
	BString SelectedFileTMP;
	BString FileExtension;
	BString tmp;
	
	//get file extension
	SelectedFile->CopyInto(SelectedFileTMP, 0, (int)SelectedFile->Length());
	SelectedFileTMP.RemoveAll("/");
	for(int i = 3; i > 0; i--) {
		tmp.SetTo(SelectedFileTMP.ByteAt((SelectedFileTMP.Length() - i)), 1);
		FileExtension.Insert(tmp.String(), FileExtension.Length());
	}
	
	FileExtension.ToUpper();
	if(FileExtension.Compare("CUE") == 0)
		return true;
	
	return false;
}
void php_class(const char *&txt, PopupList &pul, BString &className, bool sorted)
{
	BString label;

	txt = skip_whitespace(txt+5);
	const char *beg = txt;
	while (isident(*++txt)) ;
	className.SetTo(beg, txt-beg);

	while (*++txt && *txt != '{') ;

//	txt = skip_whitespace(txt);
//	if (*txt == '(') {
//		const char* beg = txt;
//		txt = skip_block(txt+1, '(', ')');
//		params.SetTo(beg+1, txt-beg-2);
//		params.Prepend("  (");
//		params.Append(")");
//	}
	if (!sorted)
		pul.insert(pul.end(), PopupMenu(className, className, beg, true));
} /* php_class */
Example #11
0
/*static*/ void
BLayoutUtils::_GetLayoutTreeDump(BView* view, int level, BString& _output)
{
	BString indent;
	indent.SetTo(' ', level * 2);

	if (view == NULL) {
		_output << indent << "<null view>\n";
		return;
	}

	BRect frame = view->Frame();
	BSize min = view->MinSize();
	BSize max = view->MinSize();
	BSize preferred = view->PreferredSize();
	_output << BString().SetToFormat(
		"%sview %p (%s):\n"
		"%s  frame: (%f, %f, %f, %f)\n"
		"%s  min:   (%f, %f)\n"
		"%s  max:   (%f, %f)\n"
		"%s  pref:  (%f, %f)\n",
		indent.String(), view, typeid(*view).name(),
		indent.String(), frame.left, frame.top, frame.right, frame.bottom,
		indent.String(), min.width, min.height,
		indent.String(), max.width, max.height,
		indent.String(), preferred.width, preferred.height);

	if (BLayout* layout = view->GetLayout()) {
		_GetLayoutTreeDump(layout, level, true, _output);
		return;
	}

	int32 count = view->CountChildren();
	for (int32 i = 0; i < count; i++) {
		_output << indent << "  ---\n";
		_GetLayoutTreeDump(view->ChildAt(i), level + 1, _output);
	}
}
Example #12
0
status_t
ParseFilter::ProcessMailMessage(BPositionIO **data, BEntry */*entry*/, BMessage *headers,
	BPath */*folder*/, const char */*uid*/)
{
	char byte;
	(*data)->ReadAt(0,&byte, 1);
	(*data)->Seek(SEEK_SET, 0);

	status_t status = parse_header(*headers, **data);
	if (status < B_OK)
		return status;

	//
	// add pseudo-header THREAD, that contains the subject
	// minus stuff in []s (added by mailing lists) and
	// Re: prefixes, added by mailers when you reply.
	// This will generally be the "thread subject".
	//
	BString string;
	string.SetTo(headers->FindString("Subject"));
	SubjectToThread(string);
	headers->AddString("THREAD", string.String());

	// name
	if (headers->FindString(fNameField.String(), 0, &string) == B_OK) {
		extract_address_name(string);
		headers->AddString("NAME", string);
	}

	// header length
	headers->AddInt32(B_MAIL_ATTR_HEADER, (int32)((*data)->Position()));
	// What about content length?  If we do that, we have to D/L the
	// whole message...
	//--NathanW says let the disk consumer do that
	
	(*data)->Seek(0, SEEK_SET);
	return B_OK;
}
Example #13
0
status_t
BNetworkRoster::AddPersistentNetwork(const wireless_network& network)
{
	BMessage message(kMsgAddPersistentNetwork);
	BString networkName;
	networkName.SetTo(network.name, sizeof(network.name));
	status_t status = message.AddString("name", networkName);
	if (status == B_OK) {
		BNetworkAddress address = network.address;
		status = message.AddFlat("address", &address);
	}

	if (status == B_OK)
		status = message.AddUInt32("flags", network.flags);
	if (status == B_OK) {
		status = message.AddUInt32("authentication_mode",
			network.authentication_mode);
	}
	if (status == B_OK)
		status = message.AddUInt32("cipher", network.cipher);
	if (status == B_OK)
		status = message.AddUInt32("group_cipher", network.group_cipher);
	if (status == B_OK)
		status = message.AddUInt32("key_mode", network.key_mode);

	if (status != B_OK)
		return status;

	BMessenger networkServer(kNetServerSignature);
	BMessage reply;
	status = networkServer.SendMessage(&message, &reply);
	if (status == B_OK)
		reply.FindInt32("status", &status);

	return status;
}
void PanelView::Calculate(CustomListItem *item)
////////////////////////////////////////////////////////////////////////
{
//	SetMousePointer(CR_HOURGLASS);
	MAINWINDOW->SetMousePointer(GenesisWindow::CR_HOURGLASS);

	if (item->m_Type==FT_DIRECTORY)
	{
		BString file;

		file.SetTo(m_Path.String());
		file+="/";
		file+=item->m_FileName;

		item->m_FileSize = GetDirectorySize(file.String());
		m_CustomListView->InvalidateItem(m_CustomListView->IndexOf(item));
	}
	
	m_CurrentTotalSize = m_CustomListView->GetCurrentTotalSize();
	SelectionChanged();		// Because the total directory size may change...
	
//	SetMousePointer(CR_DEFAULT);
	MAINWINDOW->SetMousePointer(GenesisWindow::CR_DEFAULT);
}
Example #15
0
status_t TConfigFile::Load()
{
	int32 textlen;
	char text[2048], *value;
	BString buff;
	config_t *item;
	FILE *fd = fopen(fPathName.String(), "r");
	if (!fd) return errno;
	while (!feof(fd)) {
		if (fgets(text, sizeof(text), fd) == NULL) break;
		buff.Append(text);
		textlen = strlen(text);
		if (text[textlen - 1] == '\n') {
			buff.RemoveLast("\n");
			value = strchr(buff.String(), ' ');
			if (value != NULL) {
				if ((item = (config_t *)calloc(sizeof(config_t), 1)) == NULL) {
					fclose(fd);
					return ENOMEM;
				}
				if (!fList.AddItem(item)) {
					free(item);
					fclose(fd);
					return ENOMEM;
				}
				*value = 0;
				value++;
				strncpy(item->key, buff.String(), sizeof(item->key));
				strncpy(item->value, value, sizeof(item->value));
			}
			buff.SetTo("");
		}
	}
	fclose(fd);
	return B_OK;
}
Example #16
0
status_t
BinaryOpNode::GetString(BString &predicate)
{
	status_t error = (fChild1 && fChild2 ? B_OK : B_BAD_VALUE);
	BString childString1;
	BString childString2;
	if (error == B_OK)
		error = fChild1->GetString(childString1);
	if (error == B_OK)
		error = fChild2->GetString(childString2);
	predicate.SetTo("");
	if (error == B_OK) {
		switch (fOp) {
			case B_EQ:
				predicate << "(" << childString1 << "=="
					<< childString2 << ")";
				break;
			case B_GT:
				predicate << "(" << childString1 << ">"
					<< childString2 << ")";
				break;
			case B_GE:
				predicate << "(" << childString1 << ">="
					<< childString2 << ")";
				break;
			case B_LT:
				predicate << "(" << childString1 << "<"
					<< childString2 << ")";
				break;
			case B_LE:
				predicate << "(" << childString1 << "<="
					<< childString2 << ")";
				break;
			case B_NE:
				predicate << "(" << childString1 << "!="
					<< childString2 << ")";
				break;
			case B_CONTAINS:
				if (StringNode *strNode = dynamic_cast<StringNode*>(fChild2)) {
					BString value;
					value << "*" << strNode->Value() << "*";
					error = StringNode(value.String()).GetString(childString2);
				}
				if (error == B_OK) {
					predicate << "(" << childString1 << "=="
						<< childString2 << ")";
				}
				break;
			case B_BEGINS_WITH:
				if (StringNode *strNode = dynamic_cast<StringNode*>(fChild2)) {
					BString value;
					value << strNode->Value() << "*";
					error = StringNode(value.String()).GetString(childString2);
				}
				if (error == B_OK) {
					predicate << "(" << childString1 << "=="
						<< childString2 << ")";
				}
				break;
			case B_ENDS_WITH:
				if (StringNode *strNode = dynamic_cast<StringNode*>(fChild2)) {
					BString value;
					value << "*" << strNode->Value();
					error = StringNode(value.String()).GetString(childString2);
				}
				if (error == B_OK) {
					predicate << "(" << childString1 << "=="
						<< childString2 << ")";
				}
				break;
			case B_AND:
				predicate << "(" << childString1 << "&&"
					<< childString2 << ")";
				break;
			case B_OR:
				predicate << "(" << childString1 << "||"
					<< childString2 << ")";
				break;
			default:
				error = B_BAD_VALUE;
				break;
		}
	}
	return error;
}
Example #17
0
status_t
AttributeNode::GetString(BString &predicate)
{
	predicate.SetTo(fAttribute);
	return B_OK;
}
Example #18
0
int32
CreateParamsPanel::Go(off_t& offset, off_t& size, BString& name,
	BString& type, BString& parameters)
{
	// run the window thread, to get an initial layout of the controls
	Hide();
	Show();
	if (!Lock())
		return GO_CANCELED;

	// center the panel above the parent window
	CenterIn(fWindow->Frame());

	Show();
	Unlock();

	// block this thread now, but keep the window repainting
	while (true) {
		status_t err = acquire_sem_etc(fExitSemaphore, 1,
			B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT, 50000);
		if (err != B_TIMED_OUT && err != B_INTERRUPTED)
			break;
		fWindow->UpdateIfNeeded();
	}

	if (!Lock())
		return GO_CANCELED;

	if (fReturnValue == GO_SUCCESS) {
		// Return the value back as bytes.
		size = (off_t)fSizeSlider->Size() * kMegaByte;
		offset = (off_t)fSizeSlider->Offset() * kMegaByte;

		// get name
		name.SetTo(fNameTextControl->Text());

		// get type
		if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked()) {
			const char* _type;
			BMessage* message = item->Message();
			if (!message || message->FindString("type", &_type) < B_OK)
				_type = kPartitionTypeBFS;
			type << _type;
		}

		// get editors parameters
		if (fEditor != NULL) {
			if (fEditor->FinishedEditing()) {
				status_t status = fEditor->GetParameters(&parameters);
				if (status != B_OK)
					fReturnValue = status;
			}
		}
	}

	int32 value = fReturnValue;

	Quit();
		// NOTE: this object is toast now!

	return value;
}
Example #19
0
void FoldLineAtWhiteSpaceAndAddCRLF (BString &string)
{
	int			inputLength = string.Length();
	int			lineStartIndex;
	const int	maxLineLength = 78; // Doesn't include CRLF.
	BString		output;
	int			splitIndex;
	int			tempIndex;

	lineStartIndex = 0;
	while (true) {
		// If we don't need to wrap the text, just output the remainder, if any.

		if (lineStartIndex + maxLineLength >= inputLength) {
			if (lineStartIndex < inputLength) {
				output.Insert (string, lineStartIndex /* source offset */,
					inputLength - lineStartIndex /* count */,
					output.Length() /* insert at */);
				output.Append (CRLF);
			}
			break;
		}

		// Look ahead for a convenient spot to split it, between a comma and
		// space, which you often see between e-mail addresses like this:
		// "Joe Who" [email protected], "Someone Else" [email protected]

		tempIndex = lineStartIndex + maxLineLength;
		if (tempIndex > inputLength)
			tempIndex = inputLength;
		splitIndex = string.FindLast (", ", tempIndex);
		if (splitIndex >= lineStartIndex)
			splitIndex++; // Point to the space character.

		// If none of those exist, try splitting at any white space.

		if (splitIndex <= lineStartIndex)
			splitIndex = string.FindLast (" ", tempIndex);
		if (splitIndex <= lineStartIndex)
			splitIndex = string.FindLast ("\t", tempIndex);

		// If none of those exist, allow for a longer word - split at the next
		// available white space.

		if (splitIndex <= lineStartIndex)
			splitIndex = string.FindFirst (" ", lineStartIndex + 1);
		if (splitIndex <= lineStartIndex)
			splitIndex = string.FindFirst ("\t", lineStartIndex + 1);

		// Give up, the whole rest of the line can't be split, just dump it
		// out.

		if (splitIndex <= lineStartIndex) {
			if (lineStartIndex < inputLength) {
				output.Insert (string, lineStartIndex /* source offset */,
					inputLength - lineStartIndex /* count */,
					output.Length() /* insert at */);
				output.Append (CRLF);
			}
			break;
		}

		// Do the split.  The current line up to but not including the space
		// gets output, followed by a CRLF.  The space remains to become the
		// start of the next line (and that tells the message reader that it is
		// a continuation line).

		output.Insert (string, lineStartIndex /* source offset */,
			splitIndex - lineStartIndex /* count */,
			output.Length() /* insert at */);
		output.Append (CRLF);
		lineStartIndex = splitIndex;
	}
	string.SetTo (output);
}
Example #20
0
_EXPORT void
extract_address_name(BString &header)
{
	BString name;
	const char *start = header.String();
	const char *stop = start + strlen (start);

	// Find a string S in the header (email foo) that matches:
	//   Old style name in brackets: [email protected] (S)
	//   New style quotes: "S" <*****@*****.**>
	//   New style no quotes if nothing else found: S <*****@*****.**>
	//   If nothing else found then use the whole thing: S

	for (int i = 0; i <= 3; i++) {
		// Set p1 to the first letter in the name and p2 to just past the last
		// letter in the name.  p2 stays NULL if a name wasn't found in this
		// pass.
		const char *p1 = NULL, *p2 = NULL;

		switch (i) {
			case 0: // [email protected] (S)
				if ((p1 = strchr(start,'(')) != NULL) {
					p1++; // Advance to first letter in the name.
					size_t nest = 1; // Handle nested brackets.
					for (p2 = p1; p2 < stop; ++p2)
					{
						if (*p2 == ')')
							--nest;
						else if (*p2 == '(')
							++nest;
						if (nest <= 0)
							break;
					}
					if (nest != 0)
						p2 = NULL; // False alarm, no terminating bracket.
				}
				break;
			case 1: // "S" <*****@*****.**>
				if ((p1 = strchr(start, '\"')) != NULL)
					p2 = strchr(++p1, '\"');
				break;
			case 2: // S <*****@*****.**>
				p1 = start;
				if (name.Length() == 0)
					p2 = strchr(start, '<');
				break;
			case 3: // S
				p1 = start;
				if (name.Length() == 0)
					p2 = stop;
				break;
		}

		// Remove leading and trailing space-like characters and save the
		// result if it is longer than any other likely names found.
		if (p2 != NULL) {
			while (p1 < p2 && (isspace (*p1)))
				++p1;

			while (p1 < p2 && (isspace (p2[-1])))
				--p2;

			int newLength = p2 - p1;
			if (name.Length() < newLength)
				name.SetTo(p1, newLength);
		}
	}

	int32 lessIndex = name.FindFirst('<');
	int32 greaterIndex = name.FindLast('>');

	if (lessIndex == 0) {
		// Have an address of the form <address> and nothing else, so remove
		// the greater and less than signs, if any.
		if (greaterIndex > 0)
			name.Remove(greaterIndex, 1);
		name.Remove(lessIndex, 1);
	} else if (lessIndex > 0 && lessIndex < greaterIndex) {
		// Yahoo stupidly inserts the e-mail address into the name string, so
		// this bit of code fixes: "Joe <*****@*****.**>" <*****@*****.**>
		name.Remove(lessIndex, greaterIndex - lessIndex + 1);
	}

	trim_white_space(name);
	header = name;
}
Example #21
0
//----------------------------------------------------------------
void mApp::NotificationThread()
{
BString FileName;
BString FolderPath;
BString FilePath;
BPath Path;
BString tmpString;
BString tmpString2;
BString tmpString3;
MSave Save("Save");
int TodayMinute;
int TodayHour;
int NowMinute;
int NowHour;
time_t tmptodaytime;
struct tm *TodayTime;
BString Output;
BEntry Entry("/boot/home");
	while(RunNotification)
	{
	_mWindow->Lock();
	tmpString.SetTo("");
	tmpString << _mWindow->_CalenderView->mCalender->ThisDay();
	tmpString << "-";
	tmpString << _mWindow->_CalenderView->mCalender->ThisMonth();
	tmpString << _mWindow->_CalenderView->mCalender->ThisYear();
	_mWindow->Unlock();
	
	find_directory(B_COMMON_SETTINGS_DIRECTORY, &Path);
	FolderPath.SetTo(Path.Path());
	FolderPath << SAVE_NOTE_PATH;
		for (int a = 1; a <= INT_MAXFILES; a++)
		{
		Path.SetTo(FolderPath.String());
		FileName.SetTo(tmpString.String());
		FileName << "-" << a;
		Path.Append(FileName.String());
		Entry.SetTo(Path.Path());
			if (Entry.Exists())
			{
			Save.FindString(FolderPath.String(), FileName.String(), SAVE_FILE_TYPE, &tmpString2, "M_ERROR");
			Save.FindString(FolderPath.String(), FileName.String(), SAVE_FILE_NOTIFY, &tmpString3, "M_ERROR");
				if (!strcmp(tmpString2.String(), "Apointment") && !strcmp(tmpString3.String(), "true"))
				{
				time(&tmptodaytime);
				TodayTime = localtime(&tmptodaytime);
				TodayMinute = TodayTime->tm_min;
				TodayHour   = TodayTime->tm_hour;
				
				Save.FindString(FolderPath.String(), FileName.String(), SAVE_FILE_TIME, &tmpString2, "M_ERROR");
				tmpString2.Remove(tmpString2.FindFirst(":"), tmpString2.CountChars() - tmpString2.FindFirst(":"));
				NowHour = atoi(tmpString2.String());
				
				Save.FindString(FolderPath.String(), FileName.String(), SAVE_FILE_TIME, &tmpString2, "M_ERROR");
				tmpString2.Remove(0, tmpString2.FindFirst(":") + 1);	
				NowMinute = atoi(tmpString2.String());
					if (NowMinute == TodayMinute && NowHour == TodayHour)
					{
					Save.FindString(FolderPath.String(), FileName.String(), SAVE_FILE_TITLE, &tmpString2, "M_ERROR");
					Save.FindString(FolderPath.String(), FileName.String(), SAVE_FILE_NOTE, &tmpString3, "M_ERROR");
					Output.SetTo(tmpString2.String());
					Output << "\n\n" << tmpString3.String();
					MPostit * mPostIt = new  MPostit(tmpString2.String(), Output.String(), STR_OK[INT_LANGUAGE]);
					mPostIt->Go();
					Save.AddString(FolderPath.String(), FileName.String(), SAVE_FILE_NOTIFY, "false", true);
					}
				}
				else if (!strcmp(tmpString2.String(), "Script") && !strcmp(tmpString3.String(), "true"))
				{
				time(&tmptodaytime);
				TodayTime = localtime(&tmptodaytime);
				TodayMinute = TodayTime->tm_min;
				TodayHour   = TodayTime->tm_hour;
								Save.FindString(FolderPath.String(), FileName.String(), SAVE_FILE_TIME, &tmpString2, "M_ERROR");
				tmpString2.Remove(tmpString2.FindFirst(":"), tmpString2.CountChars() - tmpString2.FindFirst(":"));
				NowHour = atoi(tmpString2.String());
								Save.FindString(FolderPath.String(), FileName.String(), SAVE_FILE_TIME, &tmpString2, "M_ERROR");
				tmpString2.Remove(0, tmpString2.FindFirst(":") + 1);	
				NowMinute = atoi(tmpString2.String());
					if (NowMinute == TodayMinute && NowHour == TodayHour)
					{
					Save.FindString(FolderPath.String(), FileName.String(), SAVE_FILE_NOTE, &tmpString, "M_ERROR");
					find_directory(B_COMMON_SETTINGS_DIRECTORY, &Path);
					FolderPath.SetTo(Path.Path());
					FolderPath << SAVE_PATH_PART_1 << SAVE_PATH_PART_2;
					FileName.SetTo("TempRunScript");
					FilePath.SetTo("");
					FilePath << FolderPath.String() << FileName.String();
					tmpString2.SetTo("chmod 666 ");
					tmpString2 << FilePath.String();
					//Save
					system(tmpString2.String());
					FILE* file = fopen(FilePath.String(), "w");
					fprintf(file, tmpString.String());
					fclose(file);
					tmpString2.SetTo("chmod 755 ");
					tmpString2 << FilePath.String();
					system(tmpString2.String());
					//Run
					system(FilePath.String());
					Save.AddString(FolderPath.String(), FileName.String(), SAVE_FILE_NOTIFY, "false", true);
					}
				}
			}
		//Add more
		}
	sleep(59);
	}
}
Example #22
0
//---------------------------------------------------------------
void ExportWindow::MainLoop()
{
BString fFilePath;
BString fFolderPath;
BString fFileName;
BPath Path;
BEntry Entry("/boot/home");
MSave Load("Load");

find_directory(B_COMMON_SETTINGS_DIRECTORY, &Path);
fFolderPath.SetTo(Path.Path());
fFolderPath.Append(SAVE_NOTE_PATH);

	for (int a = 1; a <= 31; a++)
	{
	fFileName.SetTo("");
	fFileName << a << "-" << fMonth << fYear << "-";
		for (int b = 1; b <= INT_MAXFILES; b++)
		{
		fFileName << b;
		fFilePath.SetTo(fFolderPath);
		fFilePath << fFileName.String();
		Entry.SetTo(fFilePath.String());
			if (Entry.Exists())
			{
			Load.FindString(fFilePath.String(), SAVE_FILE_TYPE, &fType, "M_ERROR");
				
				if (!strcmp(fType.String(), "Note") || !strcmp(fType.String(), "Apointment"))
				{
					//Add the date if it is the first note/apointment of this day
					if (fFirstNoteOfTheDay)
					{
					fContent << "<table width=450 color=\"#FFFFFF\">\n";
					fContent << "<h2>" << a << "." << fMonth << "-" << fYear << "</h2>\n";
					fFirstNoteOfTheDay = false;
					}
					
					//Change the color
					if (!strcmp(TableColor.String(), TableBGColor1.String()))
					{
					TableColor.SetTo(TableBGColor2);
					}
					else
					{
					TableColor.SetTo(TableBGColor1);
					}	
				}
				
				//Its a note
				if (!strcmp(fType.String(), "Note") && _ExportView->mNoteCheckBox->Value())
				{
				Load.FindString(fFilePath.String(), SAVE_FILE_NOTE, &fNote, "M_ERROR");
				Load.FindString(fFilePath.String(), SAVE_FILE_TITLE, &fTitle, "M_ERROR");
				
				fContent << "<tr><td bgcolor=\"" << TableColor.String() << "\" width=430>\n";
				fContent << "<h4>"<< fTitle.String() << "</h4>";
				fNote.ReplaceAll("\n", "<br>");
				fContent << fNote.String() << "\n";
				fContent << "</tr></td>\n";
				}
				
				//Its an apointment
				if (!strcmp(fType.String(), "Apointment") && _ExportView->mApointmentCheckBox->Value())
				{
				Load.FindString(fFilePath.String(), SAVE_FILE_NOTE, &fNote, "M_ERROR");
				Load.FindString(fFilePath.String(), SAVE_FILE_TITLE, &fTitle, "M_ERROR");
				Load.FindString(fFilePath.String(), SAVE_FILE_TIME, &fTime, "M_ERROR");
				
				fContent << "<tr><td bgcolor=\"" << TableColor.String() << "\" width=430>\n";
				fContent << "<h4>"<< fTitle.String() << "";
				
				tmpString.SetTo(fTime);
				tmpString.Remove(0, tmpString.FindFirst(":") + 1);
					if (tmpString.CountChars() == 1)
					{
					fTime.RemoveLast(tmpString.String());
					fTime.Append("0");
					fTime.Append(tmpString.String());
					}
				fContent << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"<< fTime.String() << "</h4>\n";
				fNote.ReplaceAll("\n", "<br>");
				fContent << fNote.String() << "\n";
				fContent << "</tr></td>\n";
				}
			}
		tmpString.SetTo("");
		tmpString << b;
		fFileName.RemoveLast(tmpString.String());
		}
		if (!fFirstNoteOfTheDay)
		{
		fContent << "</table>\n";
		fContent << "<br>";
		}
	fFirstNoteOfTheDay = true;
	}
}
Example #23
0
void
TMailApp::RefsReceived(BMessage *msg)
{
	bool		have_names = false;
	BString		names;
	char		type[B_FILE_NAME_LENGTH];
	int32		item = 0;
	BFile		file;
	TMailWindow	*window;
	entry_ref	ref;

	//
	// If a tracker window opened me, get a messenger from it.
	//
	BMessenger messenger;
	if (msg->HasMessenger("TrackerViewToken"))
		msg->FindMessenger("TrackerViewToken", &messenger);

	while (msg->HasRef("refs", item)) {
		msg->FindRef("refs", item++, &ref);
		if ((window = FindWindow(ref)) != NULL)
			window->Activate(true);
		else {
			file.SetTo(&ref, O_RDONLY);
			if (file.InitCheck() == B_NO_ERROR) {
				BNodeInfo	node(&file);
				node.GetType(type);
				if (strcmp(type, B_MAIL_TYPE) == 0
					|| strcmp(type, B_PARTIAL_MAIL_TYPE) == 0) {
					window = NewWindow(&ref, NULL, false, &messenger);
					window->Show();
				} else if(strcmp(type, "application/x-person") == 0) {
					/* Got a People contact info file, see if it has an Email address. */
					BString name;
					BString email;
					attr_info	info;
					char *attrib;

					if (file.GetAttrInfo("META:email", &info) == B_NO_ERROR) {
						attrib = (char *) malloc(info.size + 1);
						file.ReadAttr("META:email", B_STRING_TYPE, 0, attrib, info.size);
						attrib[info.size] = 0; // Just in case it wasn't NUL terminated.
						email << attrib;
						free(attrib);

						/* we got something... */
						if (email.Length() > 0) {
							/* see if we can get a username as well */
							if(file.GetAttrInfo("META:name", &info) == B_NO_ERROR) {
								attrib = (char *) malloc(info.size + 1);
								file.ReadAttr("META:name", B_STRING_TYPE, 0, attrib, info.size);
								attrib[info.size] = 0; // Just in case it wasn't NUL terminated.
								name << "\"" << attrib << "\" ";
								email.Prepend("<");
								email.Append(">");
								free(attrib);
							}

							if (names.Length() == 0) {
								names << name << email;
							} else {
								names << ", " << name << email;
							}
							have_names = true;
							email.SetTo("");
							name.SetTo("");
						}
					}
				}
				else if (strcmp(type, kDraftType) == 0) {
					window = NewWindow();

					// If it's a draft message, open it
					window->OpenMessage(&ref);
					window->Show();
				}
			} /* end of else(file.InitCheck() == B_NO_ERROR */
		}
	}

	if (have_names) {
		window = NewWindow(NULL, names.String());
		window->Show();
	}
}
Example #24
0
void
InspectorWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_THREAD_STATE_CHANGED:
		{
			::Thread* thread;
			if (message->FindPointer("thread",
					reinterpret_cast<void**>(&thread)) != B_OK) {
				break;
			}

			BReference< ::Thread> threadReference(thread, true);
			if (thread->State() == THREAD_STATE_STOPPED) {
				if (fCurrentBlock != NULL) {
					_SetCurrentBlock(NULL);
					_SetToAddress(fCurrentAddress);
				}
			}
			break;
		}
		case MSG_INSPECT_ADDRESS:
		{
			target_addr_t address = 0;
			if (message->FindUInt64("address", &address) != B_OK) {
				if (fAddressInput->TextView()->TextLength() == 0)
					break;

				fExpressionInfo->SetTo(fAddressInput->Text());

				fListener->ExpressionEvaluationRequested(fLanguage,
					fExpressionInfo);
			} else
				_SetToAddress(address);
			break;
		}
		case MSG_EXPRESSION_EVALUATED:
		{
			BString errorMessage;
			BReference<ExpressionResult> reference;
			ExpressionResult* value = NULL;
			if (message->FindPointer("value",
					reinterpret_cast<void**>(&value)) == B_OK) {
				reference.SetTo(value, true);
				if (value->Kind() == EXPRESSION_RESULT_KIND_PRIMITIVE) {
					Value* primitive = value->PrimitiveValue();
					BVariant variantValue;
					primitive->ToVariant(variantValue);
					if (variantValue.Type() == B_STRING_TYPE) {
						errorMessage.SetTo(variantValue.ToString());
					} else {
						_SetToAddress(variantValue.ToUInt64());
						break;
					}
				}
			} else {
				status_t result = message->FindInt32("result");
				errorMessage.SetToFormat("Failed to evaluate expression: %s",
					strerror(result));
			}

			BAlert* alert = new(std::nothrow) BAlert("Inspect Address",
				errorMessage.String(), "Close");
			if (alert != NULL)
				alert->Go();
			break;
		}

		case MSG_NAVIGATE_PREVIOUS_BLOCK:
		case MSG_NAVIGATE_NEXT_BLOCK:
		{
			if (fCurrentBlock != NULL) {
				target_addr_t address = fCurrentBlock->BaseAddress();
				if (message->what == MSG_NAVIGATE_PREVIOUS_BLOCK)
					address -= fCurrentBlock->Size();
				else
					address += fCurrentBlock->Size();

				BMessage setMessage(MSG_INSPECT_ADDRESS);
				setMessage.AddUInt64("address", address);
				PostMessage(&setMessage);
			}
			break;
		}
		case MSG_MEMORY_BLOCK_RETRIEVED:
		{
			TeamMemoryBlock* block = NULL;
			status_t result;
			if (message->FindPointer("block",
					reinterpret_cast<void **>(&block)) != B_OK
				|| message->FindInt32("result", &result) != B_OK) {
				break;
			}

			if (result == B_OK) {
				_SetCurrentBlock(block);
				fPreviousBlockButton->SetEnabled(true);
				fNextBlockButton->SetEnabled(true);
			} else {
				BString errorMessage;
				errorMessage.SetToFormat("Unable to read address 0x%" B_PRIx64
					": %s", block->BaseAddress(), strerror(result));

				BAlert* alert = new(std::nothrow) BAlert("Inspect address",
					errorMessage.String(), "Close");
				if (alert == NULL)
					break;

				alert->Go(NULL);
				block->ReleaseReference();
			}
			break;
		}
		case MSG_EDIT_CURRENT_BLOCK:
		{
			_SetEditMode(true);
			break;
		}
		case MSG_MEMORY_DATA_CHANGED:
		{
			if (fCurrentBlock == NULL)
				break;

			target_addr_t address;
			if (message->FindUInt64("address", &address) == B_OK
				&& address >= fCurrentBlock->BaseAddress()
				&& address < fCurrentBlock->BaseAddress()
					+ fCurrentBlock->Size()) {
				fCurrentBlock->Invalidate();
				_SetEditMode(false);
				fListener->InspectRequested(address, this);
			}
			break;
		}
		case MSG_COMMIT_MODIFIED_BLOCK:
		{
			// TODO: this could conceivably be extended to detect the
			// individual modified regions and only write those back.
			// That would require potentially submitting multiple separate
			// write requests, and thus require tracking all the writes being
			// waited upon for completion.
			fListener->MemoryWriteRequested(fCurrentBlock->BaseAddress(),
				fMemoryView->GetEditedData(), fCurrentBlock->Size());
			break;
		}
		case MSG_REVERT_MODIFIED_BLOCK:
		{
			_SetEditMode(false);
			break;
		}
		default:
		{
			BWindow::MessageReceived(message);
			break;
		}
	}
}
void PanelView::CreateLinkOnDesktop(void)
////////////////////////////////////////////////////////////////////////
{
	BString text;
	CustomListItem *item;
	
	if (m_PanelMode != PM_NORMAL) return;

	int n = m_CustomListView->CountSelectedEntries(CT_WITHOUTPARENT);

	// Ha a Parent-en all...
	if (n==0)
		return;

	// Let's construct the warning message...
	if (n==1)
	{
		item = m_CustomListView->GetSelectedEntry(0);	
		if (item->m_Type==FT_PARENT) // Azon ritka esetek egyike amivel meg lehetett szivatni a programot...
			item = m_CustomListView->GetSelectedEntry(1);

		text.SetTo("Do you want to create a symbolic link on the Desktop for '");
		text+=item->m_FileName;
		text+="'?";
	}
	else
	{
		text.SetTo("Do you want to create symbolic links on the Desktop for ");
		text << n;
		text+=" files?";
	}

	// Let's display the warning message...
	BAlert *WarningAlert = new BAlert("Confirm",text.String(),"Cancel","Yes",NULL,B_WIDTH_AS_USUAL,B_OFFSET_SPACING,B_WARNING_ALERT);
	WarningAlert->SetShortcut(0, B_ESCAPE);
	if (WarningAlert->Go()==1)
	{
		BString name;
		BString linkpath;
		BSymLink dstlink;
		BPath DesktopPath;
		find_directory(B_DESKTOP_DIRECTORY, &DesktopPath, true);
		
		BDirectory dstdir(DesktopPath.Path());
		
		item = m_CustomListView->GetSelectedEntry(0);
		
		while (item)
		{
			if (item->m_Type==FT_PARENT)
			{
				item = m_CustomListView->GetSelectedEntry(0);
				continue;
			}
		
			name.SetTo(item->m_FileName);
			name << " link";
		
			linkpath.SetTo(item->m_FilePath.String());
			linkpath << "/" << item->m_FileName;
		
			dstdir.CreateSymLink(name.String(), linkpath.String(), &dstlink);
			
			m_CustomListView->Deselect(m_CustomListView->IndexOf(item));
			m_CustomListView->InvalidateItem(m_CustomListView->IndexOf(item));

			item = m_CustomListView->GetSelectedEntry(0);
		}
	}
}
////////////////////////////////////////////////////////////////////////
// When the user pressed the Enter or double-clicked...
void PanelView::Execute(CustomListItem *item)
////////////////////////////////////////////////////////////////////////
{
	BString execute;

	switch (item->m_Type)
	{
		case FT_DISKITEM:
			SetPanelMode(PM_NORMAL);
			ChangePath(item->m_DiskPath.String());			
			break;
		case FT_DISKBACK:
			SetPanelMode(PM_NORMAL);
			ChangePath(m_Path.String());
			break;
		case FT_PARENT:
			GotoParent();
			break;
		case FT_DIRECTORY:
			EnterDirectory(item->m_FileName.String());
			break;
		case FT_SYMLINKDIR:
		case FT_SYMLINKFILE:	// TODO: ha mar ugyis tudjuk elore....
			{
				BEntry symlinkentry;
				entry_ref ref;

				execute.SetTo(m_Path.String());
				execute+="/";
				execute+=item->m_FileName;

				BEntry entry(execute.String());
				entry.GetRef(&ref);
				symlinkentry.SetTo(&ref, true);
				if (symlinkentry.IsDirectory())		// Is it a directory?
				{
					BPath symlinkpath;
					symlinkentry.GetPath(&symlinkpath);
					ChangePath(symlinkpath.Path());
				}
				else	// No, it is a standard file....
				{
					// Launch the selected file or document...
					if (entry.GetRef(&ref) == B_OK)
						be_roster->Launch(&ref);
				}
			}
			break;
		case FT_FILE:
			{
				// Launch the selected file or document...
				entry_ref ref;

				execute.SetTo(m_Path.String());
				execute+="/";
				execute+=item->m_FileName;

				BEntry entry(execute.String());
				if (entry.GetRef(&ref) == B_OK)
					be_roster->Launch(&ref);
			}
			break;
	}
}
Example #27
0
void MonthWindowView::DrawMonth()
{
 Bmp->Lock();
 
 float y=yearStringView->Frame().bottom+h_cell;
 float x=0;
 
 if(NewMonth)
 {
  BmpView->SetHighColor(VIEW_COLOR);
  BmpView->FillRect(BRect(0,y+1,
                    BmpView->Bounds().right,todayStringView->Frame().top-6));
  BmpView->SetHighColor(0,0,0,0);
  NewMonth=false;
 }
 
 int byear=cyear; // base year
 if(tyear<byear) byear=tyear;
  
 int day1=0, m=0, k=byear;
 
 while(k<cyear)
 {
  day1++;

  if(k%4==0) // leap year?
   if((k%100!=0) || (k%400==0)) day1++; // yes
  
  k++;
 }
 while(++m<cmonth)
 {
  day1+=(monthDays[m-1]-28);
  if(m==2) if((cyear%4)==0) if((cyear%100!=0) || (cyear%400==0)) day1++;
 }
 day1++; // day1 is number of 1st day of chosen month in chosen year
 day1=day1%7;
 
 int day2=0;
 m=0;
 k=byear;
 while(k<tyear)
 {
  day2++;
  if((k%4)==0) if((k%100!=0) || (k%400==0)) day2++;
  k++;
 }
 while(++m<tmonth)
 {
  day2+=(monthDays[m-1]-28);
  if(m==2) if((tyear%4)==0) if((tyear%100!=0) || (tyear%400==0)) day2++;
 }
 day2+=tday; // day2 - number of today's day in today's year
 day2=day2%7;
 
 k=(twday==0) ? 6 : twday-1;
 
 k=k-day2+day1;
 while(k<0) k+=7;
 k=k%7;
 cwday1=k;
 
 x=w_cell*k+1;
 y+=h_cell;
 
 int qu_days=monthDays[cmonth-1]; // quantity of days in month
 
 if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
 
 BString s;
 int t=0;
 while(t<qu_days)
 {
  t++;
  
  s<<t;
  
  if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(200,0,0,0);
  BmpView->DrawString(s.String(),BPoint(x+(w_cell-StringWidth(s.String()))/2,y));
  if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(0,0,0,0);
  
  if(t==cday)
  {
   cwday=k;
   if(which_focused==2) BmpView->SetHighColor(ACTIVE_COLOR);
   else BmpView->SetHighColor(NOACTIVE_COLOR);
   cursor.Set(x,y-h_cell+5,x+w_cell-1,y+4);
   BmpView->StrokeRect(cursor);
   BmpView->SetHighColor(0,0,0,0);
  }
  
  x+=w_cell;
  k++;
  s.SetTo("");
  
  if(k==7)
  {
   k=0;
   y+=h_cell;
   x=1;
  }
 }
 
 BmpView->Sync();
 Bmp->Unlock();
 Draw(Bounds());
}
Example #28
0
//----------------------------------------------------------------
void mApp::MessageReceived(BMessage *message)
{
	switch(message->what)
	{
	case MSG_EXPORT_HTML:
		Show = true;
		for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_EXPORT_WINDOW[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_ExportWindow = new ExportWindow(BRect(100, 100, 550, 500), STR_EXPORT_WINDOW[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE, _mWindow->_CalenderView->mCalender->Month(), _mWindow->_CalenderView->mCalender->Year());
			_ExportWindow->Show();
			}
			else
			{
			_ExportWindow->Activate();
			}
	
	break;
	case MSG_ABOUT:
		//show about window
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_ABOUT_WINDOW[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_AboutWindow = new AboutWindow(BRect(100, 100, 550, 500), STR_ABOUT_WINDOW[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_AboutWindow->Show();
			}
			else
			{
			_AboutWindow->Activate();
			}
	break;
	case MSG_PREFERENCES:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_PREFERENCES_WINDOW[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_PreferencesWindow = new PreferencesWindow(BRect(100, 100, 500, 500), STR_PREFERENCES_WINDOW[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_PreferencesWindow->Show();
			}
			else
			{
			_PreferencesWindow->Activate(true);
			}
	break;
	case MSG_ADD_SCRIPT_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_ADD_SCRIPT_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_ADD_SCRIPT_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_EDIT_SCRIPT_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_EDIT_SCRIPT_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_EDIT_SCRIPT_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_ADD_NOTE_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_ADD_NOTE_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_ADD_NOTE_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_EDIT_NOTE_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_EDIT_NOTE_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_EDIT_NOTE_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_ADD_APOINTMENT_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_ADD_APOINTMENT_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_ADD_APOINTMENT_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_EDIT_APOINTMENT_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_EDIT_APOINTMENT_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_EDIT_APOINTMENT_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	//Reload the listview
	case MSG_GET_NOTES:
		_mWindow->LockLooper();
		_mWindow->GetNotes();
		_mWindow->UnlockLooper();
	break;
	case MSG_CALENDER_STYLE:
	{
		_mWindow->LockLooper();
		_mWindow->_CalenderView->mCalender->SetAmericanStyleCalender(_PreferencesWindow->_PreferencesView->mCalenderStyleCheckBox->Value());
		_mWindow->Activate();
		_mWindow->UnlockLooper();
		snooze(30000);
		_PreferencesWindow->LockLooper();
		_PreferencesWindow->Activate();
		_PreferencesWindow->UnlockLooper();
		
		MSave save("save");
		_mWindow->GetSettingsPath(&path);
		//Save Style
		save.AddBool(path, SAVE_FILE_NAME, NAME_CALENDER_STYLE, _PreferencesWindow->_PreferencesView->mCalenderStyleCheckBox->Value(), true);
	break;
	}
	case MSG_CALENDER_COLORFUL:
	{
		_mWindow->_CalenderView->mCalender->SetColorfulCalender(_PreferencesWindow->_PreferencesView->mCalenderColorCheckBox->Value());
		_mWindow->LockLooper();
		_mWindow->_CalenderView->mCalender->Draw(BRect(0, 0, 1600, 1200));
		_mWindow->Activate();
		_mWindow->UnlockLooper();
		snooze(30000);
		_PreferencesWindow->LockLooper();
		_PreferencesWindow->Activate();
		_PreferencesWindow->UnlockLooper();
		
		MSave save("save");
		_mWindow->GetSettingsPath(&path);
		//Save Style
		save.AddBool(path, SAVE_FILE_NAME, NAME_CALENDER_COLORFUL, _PreferencesWindow->_PreferencesView->mCalenderColorCheckBox->Value(), true);
	break;
	}
	case MSG_OPEN_GL_GAME:
		_Wind = new Wind(STR_HIDDEN_OPENGL_GAME[INT_LANGUAGE]);
	break;
	case MSG_CLOSE_GL_GAME:
		_Wind->Lock();
		_Wind->Close();
	break;
	case MSG_LANGUAGE_CHANGED:
	{
			MSave save("save");
			_mWindow->GetSettingsPath(&path);
			
			save.AddInt32(path, SAVE_FILE_NAME, NAME_LANGUAGE, _PreferencesWindow->_PreferencesView->mLanguageMenu->IndexOf(_PreferencesWindow->_PreferencesView->mLanguageMenu->FindMarked()), true);
			
			if (_PreferencesWindow->_PreferencesView->mLanguageMenu->IndexOf(_PreferencesWindow->_PreferencesView->mLanguageMenu->FindMarked()) != INT_LANGUAGE)
			{
			BAlert * mAlert = new BAlert("mAlert", STR_LANGUAGE_ALERT[INT_LANGUAGE], STR_RESTART_NOW[INT_LANGUAGE], STR_RESTART_LATER[INT_LANGUAGE]);
				switch(mAlert->Go())
				{
				case 0:
				{
					BString tempString;
					BString tempString2;
					BPath Path;
					find_directory(B_COMMON_SETTINGS_DIRECTORY, &Path);
					tempString.SetTo(path.Path());
					tempString.Append(SAVE_SETTINGS_PATH);
					save.FindString(tempString.String(), SAVE_FILE_NAME, NAME_EXEC_DIR, &tempString2, "M_ERROR");
					tempString2.Append(SAVE_SCRIPT_PATH);
					tempString2 << "Restart &";
					system(tempString2.String());
				break;
				}
				default:
				
				break;
				}
			}
	break;
	}
	case MSG_EXPORT_HTML_FILE:
	{
	mFilePanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_DIRECTORY_NODE,
	//mFilePanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_FILE_NODE,
					false, NULL , NULL, false, true); 
	mFilePanel->Window()->SetTitle("Save To: ");
	mFilePanel->Show();
	break;
	}
	case MSG_QUIT_PLEASE:
		RunNotification = false;
		//status_t junk;
		kill_thread(Notification);
		kill_thread(CheckForUpdate);
			while (CountWindows() > 0)
			{
			//WindowAt(CountWindows() - 1)->Lock();
			WindowAt(CountWindows() - 1)->Close();
			}
	break;
	default:
	
	break;
	}
}
Example #29
0
void
AboutView::_AddCopyrightsFromAttribute()
{
#ifdef __HAIKU__
	// open the app executable file
	char appPath[B_PATH_NAME_LENGTH];
	int appFD;
	if (BPrivate::get_app_path(appPath) != B_OK
		|| (appFD = open(appPath, O_RDONLY)) < 0) {
		return;
	}

	// open the attribute
	int attrFD = fs_fopen_attr(appFD, "COPYRIGHTS", B_STRING_TYPE, O_RDONLY);
	close(appFD);
	if (attrFD < 0)
		return;

	// attach it to a FILE
	FILE* attrFile = fdopen(attrFD, "r");
	if (attrFile == NULL) {
		close(attrFD);
		return;
	}
	CObjectDeleter<FILE, int> _(attrFile, fclose);

	// read and parse the copyrights
	BMessage package;
	BString fieldName;
	BString fieldValue;
	char lineBuffer[LINE_MAX];
	while (char* line = fgets(lineBuffer, sizeof(lineBuffer), attrFile)) {
		// chop off line break
		size_t lineLen = strlen(line);
		if (lineLen > 0 && line[lineLen - 1] == '\n')
			line[--lineLen] = '\0';

		// flush previous field, if a new field begins, otherwise append
		if (lineLen == 0 || !isspace(line[0])) {
			// new field -- flush the previous one
			if (fieldName.Length() > 0) {
				fieldValue = trim_string(fieldValue.String(),
					fieldValue.Length());
				package.AddString(fieldName.String(), fieldValue);
				fieldName = "";
			}
		} else if (fieldName.Length() > 0) {
			// append to current field
			fieldValue += line;
			continue;
		} else {
			// bogus line -- ignore
			continue;
		}

		if (lineLen == 0)
			continue;

		// parse new field
		char* colon = strchr(line, ':');
		if (colon == NULL) {
			// bogus line -- ignore
			continue;
		}

		fieldName.SetTo(line, colon - line);
		fieldName = trim_string(line, colon - line);
		if (fieldName.Length() == 0) {
			// invalid field name
			continue;
		}

		fieldValue = colon + 1;

		if (fieldName == "Package") {
			// flush the current package
			_AddPackageCredit(PackageCredit(package));
			package.MakeEmpty();
		}
	}

	// flush current package
	_AddPackageCredit(PackageCredit(package));
#endif
}
Example #30
0
status_t
BNetworkCookieJar::Unflatten(type_code, const void* buffer, ssize_t size)
{
	BString flattenedCookies;
	flattenedCookies.SetTo(reinterpret_cast<const char*>(buffer), size);

	while (flattenedCookies.Length() > 0) {
		BNetworkCookie tempCookie;
		BString tempCookieLine;

		int32 endOfLine = flattenedCookies.FindFirst('\n', 0);
		if (endOfLine == -1)
			tempCookieLine = flattenedCookies;
		else {
			flattenedCookies.MoveInto(tempCookieLine, 0, endOfLine);
			flattenedCookies.Remove(0, 1);
		}

		if (tempCookieLine.Length() != 0 && tempCookieLine[0] != '#') {
			for (int32 field = 0; field < 7; field++) {
				BString tempString;

				int32 endOfField = tempCookieLine.FindFirst('\t', 0);
				if (endOfField == -1)
					tempString = tempCookieLine;
				else {
					tempCookieLine.MoveInto(tempString, 0, endOfField);
					tempCookieLine.Remove(0, 1);
				}

				switch (field) {
					case 0:
						tempCookie.SetDomain(tempString);
						break;

					case 1:
						// TODO: Useless field ATM
						break;

					case 2:
						tempCookie.SetPath(tempString);
						break;

					case 3:
						tempCookie.SetSecure(tempString == "TRUE");
						break;

					case 4:
						tempCookie.SetExpirationDate(atoi(tempString));
						break;

					case 5:
						tempCookie.SetName(tempString);
						break;

					case 6:
						tempCookie.SetValue(tempString);
						break;
				} // switch
			} // for loop

			AddCookie(tempCookie);
		}
	}

	return B_OK;
}