Пример #1
0
ArpConfigureFile& ArpConfigureFile::operator=(const ArpConfigureFile& o)
{
    StopWatcher();

    size_t i;
    mConfigs->resize(0);
    mConfigs->reserve(o.mConfigs->size());
    for( i=0; i<o.mConfigs->size(); i++ ) mConfigs->push_back(o.mConfigs->at(i));
    mNames->resize(0);
    mNames->reserve(o.mNames->size());
    for( i=0; i<o.mNames->size(); i++ ) mNames->push_back(o.mNames->at(i));
    mFile = o.mFile;
    mMimeType = o.mMimeType;

#if 0	// Don't copy the watcher info
    mWatcher = o.mWatcher;

    delete mWatchMessage;
    mWatchMessage = 0;
    if( o.mWatchMessage ) {
        mWatchMessage = new BMessage(o.mWatchMessage);
    }
#endif

    StartWatcher();

    ArpD(cdb << ADH << "Copied ArpConfigureFile:" << endl);
    ArpD(cdb << ADH << "  src num configs = " << o.mConfigs->size()
         << ", names = " << o.mNames->size() << endl);
    ArpD(cdb << ADH << "  new num configs = " << mConfigs->size()
         << ", names = " << mNames->size() << endl);
    return *this;
}
Пример #2
0
status_t ArpConfigureFile::WriteSettings(const BMessage* from) const
{
    if( from == 0 ) return B_BAD_VALUE;

    ArpD(cdb << ADH << "ArpConfigureFile: Writing settings with BMessage: "
         << *from << endl);

    if( mFile == entry_ref() ) return B_NO_INIT;

    status_t err;

    // We seem to need to force any symbolic link to be resolved --
    // otherwise, the BFile.Flatten() fails.
    BEntry entry(&mFile, true);

    BFile file(&entry, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
    err = file.InitCheck();
    ArpD(cdb << ADH << "Result from creating file: " << err << endl);
    if( err ) return err;

    if( (err=from->Flatten(&file)) ) return err;

    ArpD(cdb << ADH << "Result from writing settings: " << err << endl);

    if( mMimeType != "" ) {
        ArpD(cdb << ADH << "Writing MIME type: " << MimeType() << endl);
        BNodeInfo info(&file);
        if( (err=info.InitCheck()) ) return err;
        err = info.SetType(mMimeType.String());
        ArpD(cdb << ADH << "Result from writing mime type: " << err << endl);
        if( err ) return err;
    }

    return err;
}
Пример #3
0
status_t ArpConfigureFile::StartWatcher(void)
{
    StopWatcher();

    ArpD(cdb << ADH << "Starting watcher..." << endl);
    if( mFile != entry_ref() && mWatcher.IsValid() ) {
        ArpD(cdb << ADH << "On file: " << Path().Path() << endl);
        BEntry entry(&mFile);
        if( entry.InitCheck() != B_OK ) return entry.InitCheck();
        status_t err = entry.GetNodeRef(&mNode);
        if( err != B_OK ) return err;

        BLooper* looper=0;
        mWatcher.Target(&looper);
        ArpD(cdb << ADH << "Target is: " << looper << endl);
        if( looper == 0 ) {
            mNode = node_ref();
            return B_ERROR;
        }

        looper->AddHandler(this);

        err = watch_node(&mNode, B_WATCH_ALL, this);
        ArpD(cdb << ADH << "Result from watch_node(): " << err << endl);
        if( err != B_OK ) {
            looper->RemoveHandler(this);
            mNode = node_ref();
            return err;
        }
    }

    return B_OK;
}
Пример #4
0
void ArpConfigurePanel::AllAttached()
{
	ArpD(cdb << ADH << "ArpConfigurePanel: All attached." << endl);
	inherited::AllAttached();
	ArpD(cdb << ADH << "Selecting the first tab..." << endl);
	SendSetPanel(FocusTab());
}
Пример #5
0
ArpAboutWindow::ArpAboutWindow(BWindow* inwin,
                               const char* appname, const char* verstr,
                               const char* build, const char* text)
    : BWindow(inwin ? inwin->Frame() : BScreen().Frame(), appname,
              B_MODAL_WINDOW_LOOK,
              B_NORMAL_WINDOW_FEEL,
              //inwin ? B_FLOATING_SUBSET_WINDOW_FEEL : B_FLOATING_APP_WINDOW_FEEL,
              B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS )
{
    if( inwin ) AddToSubset(inwin);

    ArpAboutView	*aView;
    // set up a rectangle and instantiate a new view
    BRect aRect( Bounds() );
    aView = new ArpAboutView(aRect, "AnimView", text,
                             appname, verstr, text);
    // add view to window
    AddChild(aView);

    BRect frm = Frame();
    float w=0, h=0;
    aView->GetPreferredSize(&w, &h);
    ResizeTo(w, h);
    BRect cfrm = Frame();
    ArpD(cdb << ADH << "Resized frame = " << cfrm << endl);
    MoveTo( frm.left
            + (frm.Width()-cfrm.Width())/2,
            frm.top
            + (frm.Height()-cfrm.Height())/2);
    ArpD(cdb << ADH << "Moved frame = " << Frame() << endl);
}
Пример #6
0
status_t ArpConfigureFile::SetFile(const char* name)
{
    ArpD(cdb << ADH << "ArpConfigureFile: setting file from path = "
         << name << endl);

    BEntry entry(&mFile);
    if( entry.InitCheck() != B_OK ) return entry.InitCheck();

    BPath path;
    status_t err = entry.GetPath(&path);
    if( err != B_OK ) return err;

    ArpD(cdb << ADH << "ArpConfigureFile: orig path = "
         << path << endl);

    err = path.InitCheck();
    if( err == B_OK ) err = path.GetParent(&path);
    if( err == B_OK ) err = path.Append(name);
    ArpD(cdb << ADH << "ArpConfigureFile: renamed path = "
         << path.Path() << endl);

    if( err != B_OK ) return err;

    entry.SetTo(path.Path());
    err = entry.InitCheck();
    if( err != B_OK ) return err;

    entry_ref ref;
    err = entry.GetRef(&ref);
    if( err != B_OK ) return err;

    return SetFile(ref);
}
Пример #7
0
ArpAddonManager::BasicAddon::BasicAddon(const char* path)
	: image(B_ERROR), ref_count(0)
{
	ArpD(cdb << ADH << "Setting addon path: path=" << (void*)path
				<< " (" << (path ? path : "<null>") << ")" << endl);
	if( path ) where.SetTo(path);
	ArpD(cdb << ADH << "Creating new addon for: " << where << endl);
}
Пример #8
0
ArpAddonManager::BasicAddon::BasicAddon(BEntry* entry)
	: image(B_ERROR), ref_count(0)
{
	ArpD(cdb << ADH << "Setting addon path: entry=" << (void*)entry
			<< " (init=" << entry->InitCheck()
			<< " exists=" << entry->Exists() <<")" << endl);
	if( entry ) entry->GetPath(&where);
	ArpD(cdb << ADH << "Creating new addon for: " << where << endl);
}
Пример #9
0
void ArpRemoteTerminal::AttachedToWindow(void)
{
	inherited::AttachedToWindow();
	termhand = BMessenger(this);
	ArpD(cdb << ADH << "ArpRemoteTerminal::AttachedToWindow()" << endl);
	ArpD(cdb << ADH << "Window = " << Window()
				<< "valid = " << termhand.IsValid() << endl);
	SendAttachMsg();
}
Пример #10
0
void ArpRemoteTerminal::TermReset(bool hard)
{
	ArpD(cdb << ADH << "ArpRemoteTerminal: Reset hard=" << hard << endl);
	inherited::TermReset(hard);
	if( HaveWatchers() ) {
		BMessage config;
		if( GetConfiguration(&config) == B_NO_ERROR ) {
			ArpD(cdb << ADH << "Reporting change: " << config << endl);
			ReportChange(&config);
		}
	}
}
Пример #11
0
void ArpRemoteTerminal::SetRemote(const BMessenger& dev)
{
	device = dev;
	if( device.IsValid() ) {
		termhand = BMessenger(this);
		ArpD(cdb << ADH << "ArpRemoteTerminal::SetRemote()" << endl);
		ArpD(cdb << ADH << "Window = " << Window()
					<< "valid = " << termhand.IsValid() << endl);
		if( termhand.IsValid() ) {
			SendAttachMsg();
			if( manager ) SendEmulatorsMsg();
		}
	}
}
Пример #12
0
status_t ArpConfigureFile::WriteSettings() const
{
    BMessage settings;

    ArpD(cdb << ADH << "ArpConfigureFile: Writing settings..." << endl);

    status_t err;
    if( (err=MakeSettings(&settings)) ) return err;

    ArpD(cdb << ADH << "ArpConfigureFile: Retrieved settings: "
         << settings << endl);

    return WriteSettings(&settings);
}
Пример #13
0
void ArpMenuBar::FrameResized(float new_width, float new_height)
{
#if 0
	const BRect bounds(Bounds());
	if( Window() ) {
		ArpD(cdb << ADH << "Bounds new: " << bounds
				<< ", old: " << mLastBounds << endl);
		if( bounds.Width() < mLastBounds.Width() ) {
			Invalidate(BRect(bounds.right-1, bounds.top,
							 bounds.right, bounds.bottom));
		} else if( bounds.Width() > mLastBounds.Width() ) {
			Invalidate(BRect(mLastBounds.right-1, bounds.top,
							 mLastBounds.right, bounds.bottom));
		}
		if( bounds.Height() < mLastBounds.Height() ) {
			Invalidate(BRect(bounds.left, bounds.bottom-1,
							 bounds.right, bounds.bottom));
		} else if( bounds.Height() > mLastBounds.Height() ) {
			Invalidate(BRect(bounds.left, mLastBounds.bottom-1,
							 bounds.right, mLastBounds.bottom));
		}
	}
	mLastBounds = bounds;
#endif
	BMenuBar::FrameResized(new_width, new_height);
}
Пример #14
0
void ArpDocumentButton::MouseDown(BPoint point)
{
	ArpD(cdb << ADH << "Mouse down received." << endl);
	
	BMessage* msg = Window()->CurrentMessage();
	if( !msg ) return;
	int32 button=0;
	msg->FindInt32("buttons",&button);
	
	SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS);
	mAction = ButtonPressed;
	mPressed = IsPointIn(point);
	
#if 0		// popup menu not currently implemented
	if( button == B_PRIMARY_MOUSE_BUTTON ) {
		
	} else {
		mAction = MenuPopped;
		mMenued = true;

	}
#endif
	
	Invalidate();
}
Пример #15
0
myinline const char* ArpMessage::GetIndirect(const char *name, const char* def, int32 index) const
{
	if( this ) {
		const char* res;
		if( FindIndirect(name, index, &res) != B_NO_ERROR ) return def;
		return res;
	}
	return def;
#if 0
	if( this ) {
		const char* res = NULL;
		ssize_t bytes = 0;
		if( FindData(name, ARP_INDIRECT_TYPE, index, (const void**)&res, &bytes) != B_NO_ERROR ) return def;
		if( !res ) return def;
		ArpD(cdb << ADH << "Got indirect: " << res << " for " << name
					<< " (" << bytes << " bytes)" << endl);
		if( res[bytes-1] != '\0' ) {
			printf("Oops!\n");
			return def;
		}
		return res;
	}
	return def;
#endif
}
Пример #16
0
status_t ArpMultiDir::Rewind()
{
	ArpD(cdb << ADH << "Rewinding ArpMultiDir." << endl);
	cur_dirs_index = -1;
	inherited::Unset();
	return B_OK;
}
Пример #17
0
status_t ArpMultiDir::AddEnvVar(const char* name, const char* leaf)
{
	if( !name ) return B_OK;
	
	int nlen = strlen(name);
	char** e = environ;
	while( e && *e ) {
		ArpD(cdb << ADH << "Looking at var: " << *e << endl);
		if( strncmp(*e,name,nlen) == 0 && (*e)[nlen] == '=' ) {
			ArpD(cdb << ADH << "Found env var: " << *e << endl);
			return AddSearchPath(&((*e)[nlen+1]), leaf);
		}
		e++;
	}
	return B_OK;
}
Пример #18
0
void ArpDocumentButton::MouseMoved(BPoint point, uint32 transit,
							 const BMessage* message)
{
	BMessage* curMsg = Window()->CurrentMessage();
	
	if( message ) {
		// Only update button when drag enters or leaves the view.
		if( transit != B_ENTERED_VIEW && transit != B_EXITED_VIEW ) return;
		
		BMessenger source;
		if( message->FindMessenger("ARP:source", &source) == B_OK ) {
			if( source == BMessenger(this) ) return;
		}
		bool newDropped = false;
		if( transit == B_ENTERED_VIEW ) {
			// Is this a message we can handle?
			bool control=false;
			if( curMsg ) {
				int32 modifiers=0;
				curMsg->FindInt32("modifiers",&modifiers);
				if( (modifiers&B_LEFT_CONTROL_KEY) != 0 ) control=true;
				ArpD(cdb << ADH << "Drag entered view, ctrl=" << control
							<< ", mouse move=" << *curMsg << endl);
			}
			if( control || GetDropRef(0,message) == B_OK
						|| GetDropAction(0,message) == B_OK ) {
				newDropped = true;
			}
		}
		if( newDropped != mDropped ) {
			ArpD(if( message ) cdb << "Dragged message: " << *message << endl);
			mDropped = newDropped;
			Invalidate();
		}
	}
Пример #19
0
int32 AmInputQueue::RecordThreadEntry(void* arg)
{
	ArpD(cdb << ADH << "Enter the recorder." << endl);
	AmInputQueue *obj = (AmInputQueue *)arg;
	
	int32 ret = obj->RecordLoop();
	obj->mRecordLock.Lock();
	if (obj->mRecordAvail >= B_OK) {
		delete_sem(obj->mRecordAvail);
		obj->mRecordAvail = B_BAD_SEM_ID;
	}
	obj->mRecordThread = B_BAD_THREAD_ID;
	obj->mRecordLock.Unlock();
	
	ArpD(cdb << ADH << "Exit the recorder." << endl);
	return ret;
}
Пример #20
0
void ArpConfigurePanel::AttachedToWindow()
{
	ArpD(cdb << ADH << "ArpConfigurePanel: Attached to window." << endl);
	inherited::AttachedToWindow();
	BView* par = Parent();
	if( par ) SetViewColor(par->ViewColor());
	else SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
}
Пример #21
0
status_t ArpConfigureFile::AddConfig(ArpConfigurableI* obj, const char* nm)
{
    ArpD(cdb << ADH << "Adding configurable: obj=" << obj
         << ", name=" << (nm ? nm : "<NULL>") << endl);
    mConfigs->push_back(obj);
    mNames->push_back(BString(nm));
    return B_OK;
}
Пример #22
0
void ArpAddonManager::Start(void)
{
	ArpD(cdb << ADH << "Starting addon manager" << endl);
	BAutolock(Lock());
	ArpD(cdb << ADH << "Locked myself." << endl);
	BEntry entry;
	Rewind();
	while( GetNextEntry(&entry,true) == B_NO_ERROR ) {
		if( entry.InitCheck() == B_NO_ERROR ) {
			ArpD(cdb << ADH << "Trying addon for: " << (void*)&entry << endl);
			BasicAddon* addon = AllocAddon(&entry);
			if( addon ) {
				if( addon->InitCheck() == B_NO_ERROR ) AddAddon(addon);
				else delete addon;
			}
		}
	}
}
Пример #23
0
void ArpRemoteTerminal::TermSendRemote(const ichar * d, size_t len)
{
	if( device.IsValid() ) {
		BMessage msg(TERM_XFER_TEXT_MSG);
		msg.AddData("text",B_ASCII_TYPE,d,len);
		ArpD(cdb << ADH << "ArpTerminal::TermSendRemote: " << msg << endl);
		device.SendMessage(&msg);
	}
}
Пример #24
0
status_t ArpMultiDir::AddDirectory(const char* dir, const char* leaf)
{
	BPath* path =  new BPath(dir,leaf,true);
	if( path ) {
		if( path->InitCheck() != B_OK ) return path->InitCheck();
		ArpD(cdb << ADH << "Adding directory: " << path->Path() << endl);
		for( int32 i=0; i<dirs.CountItems(); i++ ) {
			BPath* existing = (BPath*)(dirs.ItemAt(i));
			if( existing && (*existing) == (*path) ) {
				ArpD(cdb << ADH << "Already have it!" << endl);
				delete path;
				return B_OK;
			}
		}
		if( !dirs.AddItem(path) ) return B_ERROR;
		return B_OK;
	}
	return B_NO_MEMORY;
}
Пример #25
0
void TestView::Draw(BRect /*updateRect*/)
{
	ArpD(cdb << ADH << "TestView::Draw() " << Name() << endl);
	BRect frm = Bounds();
	StrokeRect(frm);
	StrokeLine(BPoint(frm.left,frm.top),
				BPoint(frm.right,frm.bottom));
	StrokeLine(BPoint(frm.right,frm.top),
				BPoint(frm.left,frm.bottom));
}
Пример #26
0
static int32 binsearch(const char** array, int32 size, const char* text)
{
	int32 curMin=0, curMax=size-1;
	ArpD(cdb << ADH << "Bin search for " << text << endl);
	while( curMin <= curMax ) {
		int32 mid = (curMin+curMax)/2;
		ArpD(cdb << ADH << "Min=" << curMin << " Mid=" << mid
					<< " Max=" << curMax << endl);
		int32 cmp = strcmp(array[mid], text);
		ArpD(cdb << ADH << "Compare with " << array[mid] << ": " << cmp << endl);
		if( cmp > 0 ) curMax=mid-1;
		else if ( cmp < 0 ) curMin=mid+1;
		else return mid;
	}
	
	ArpD(cdb << ADH << "*** Not found!" << endl);
	
	return -1;
}
Пример #27
0
void ArpConfigurePanel::GetPreferredSize(float* width, float* height)
{
	float maxw=0, maxh=0;
	size_t i;
	
	// Get dimensions of all configuration views.
	for( i=0; i<mConfigViews->size(); i++ ) {
		BView* view = 0;
		if( (view=mConfigViews->at(i)) != 0 ) {
			ArpD(cdb << ADH << "Processing dimens for view #" << i
							<< ", name="
							<< view->Name() << endl);
			float vwidth=0, vheight=0;
			// If this view is not attached to the window (i.e., it
			// is not currently displayed by the tab view), then it
			// may not be able to report correct dimensions.  To fix
			// this, we temporarily add it to your view.
			if( !view->Window() ) {
				ArpD(cdb << ADH << "Temporarily attaching view to window."
							<< endl);
				bool hidden = view->IsHidden();
				view->Hide();
				AddChild(view);
				view->GetPreferredSize(&vwidth, &vheight);
				RemoveChild(view);
				if( !hidden ) view->Show();
			} else {
				view->GetPreferredSize(&vwidth, &vheight);
			}
			ArpD(cdb << ADH << "Preferred width=" << vwidth
							<< ", height=" << vheight << endl);
			if( vwidth > maxw ) maxw = vwidth;
			if( vheight > maxh ) maxh = vheight;
		}
	}
	
	ArpD(cdb << ADH << "Final size=(" << (maxw+mTabWidth)
				<< ", " << (maxh+mTabHeight) << ")" << endl);
				
	if( width ) *width = maxw + mTabWidth + 2;
	if( height ) *height = maxh + mTabHeight + 2;
}
Пример #28
0
status_t ArpMultiDir::next_dir(void)
{
	cur_dirs_index++;
	ArpD(cdb << ADH << "Moving to next dir #" << cur_dirs_index << endl);
	if( cur_dirs_index >= dirs.CountItems() ) {
		ArpD(cdb << ADH << "At end of this directory!" << endl);
		inherited::Unset();
		return ENOENT;
	}
	
	BPath* path = (BPath*)(dirs.ItemAt(cur_dirs_index));
	if( path == NULL ) {
		ArpD(cdb << ADH << "Reached last path, it's all over." << endl);
		inherited::Unset();
		return ENOENT;
	}
	
	ArpD(cdb << ADH << "Moving to new path " << path << endl);
	return inherited::SetTo(path->Path());
}
Пример #29
0
void ArpConfigurePanel::SendSetPanel(int32 tab)
{
	BTab* tabobj = TabAt(tab);
	if( tabobj ) {
		BView* view = tabobj->View();
		if( view ) {
			BMessenger target(view);
			if( target.IsValid() ) {
				BMessage setPanel(ARP_SET_CONFIG_PANEL_MSG);
				setPanel.AddMessenger("panel", BMessenger(this));
				target.SendMessage(&setPanel);
				ArpD(cdb << ADH << "Sent config panel msg: "
						<< setPanel << endl);
			} else {
				ArpD(cdb << ADH << "Invalid messenger for view, "
						<< "couldn't send panel message!" << endl);
			}
		}
	}
}
Пример #30
0
void ArpTelnetSettings::ShowCurrentHost(const ArpMessage& settings)
{
	ArpD(cdb << ADH << "ArpTelnetSettings::ShowCurrentHost()" << endl);
	const char* host = 0;
	if( settings.FindString(ArpTelnet::HostConfigName,
							&host) == B_OK ) {
		if( mHostText ) {
			mHostText->SetText(host);
		}
	}
}