Esempio n. 1
0
PObject *
PObjectBroker::MakeObject(const char *type, BMessage *msg)
{
	if (!type)
		return NULL;
	
	if (pApp && BString(type).ICompare("PApplication") == 0)
		return pApp;
	
	PObjectInfo *info = NULL;
	for (int32 i = 0; i < fObjInfoList->CountItems(); i++)
	{
		PObjectInfo *temp = fObjInfoList->ItemAt(i);
		if (temp->type.ICompare(type) == 0)
		{
			info = temp;
			break;
		}
	}
	
	if (info)
	{
		PObject *obj = msg ? (PObject*)info->arcfunc(msg) : info->createfunc();
		fObjectList->AddItem(obj);
		
		if (!pApp && obj->GetType().Compare("PApplication") == 0)
			pApp = obj;
		
		return obj;
	}
	
	return NULL;
}
Esempio n. 2
0
	bool Person::add_role(const std::string &depid, const std::string &srole) {
		std::string role = to_lower(trim(srole));
		if (depid.empty() || role.empty()) {
			return false;
		}
		std::vector<PersonRole> oRet = this->roles();
		bool bFound = false;
		PersonRole temp(depid, role);
		for (auto it = oRet.begin(); it != oRet.end(); ++it) {
			if ((*it) == temp) {
				bFound = true;
				break;
			}
		}
		if (bFound) {
			return false;
		}
		Array *pAr = this->set_array(DomainConstants::ROLES);
		if (pAr == nullptr) {
			return false;
		}
		PObject obj = Value::create_object();
		Object *p = obj.get();
		p->set_string(STRING_DEP, depid);
		p->set_string(STRING_ROLE, role);
		pAr->append_object(obj);
		this->modified(true);
		return true;
	}// add_role
Esempio n. 3
0
int32_t
PTextViewCut(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();
	
	PArgs *inArgs = static_cast<PArgs*>(in);
	
	uint64 id = 0;
	if (inArgs->FindInt64("clipid", (int64*)&id) != B_OK)
		return B_ERROR;
	
	PObject *obj = BROKER->FindObject(id);
	if (!obj || obj->GetType().ICompare("PClipboard") != 0)
		return B_BAD_DATA;
	
	PClipboard *clip = dynamic_cast<PClipboard*>(obj);
	
	if (backend->Window())
		backend->Window()->Lock();
	
	backend->Cut(clip->GetBackend());
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
Esempio n. 4
0
void PukeController::MessageDispatch(int fd, PukeMessage *pm) 
{
    try {

        /*
         * Get the object id, this may produce a errorNuSuchWidget
         */
        PObject *obj = id2pobject(fd, pm->iWinId);

        /*
         * Call the message hanlder for the widget
         */
        obj->messageHandler(fd, pm);
    }
    catch(errorNoSuchWidget &err){
      PukeMessage pmRet;
      pmRet.iCommand = PUKE_INVALID;
      pmRet.iWinId = pm->iWinId;
      pmRet.iArg = 0;
      pmRet.iTextSize = 0;
      emit outputMessage(fd, &pmRet);
      return;
    }
   catch (errorCommandFailed &err){
      PukeMessage pmRet;
      pmRet.iCommand = err.command();
      pmRet.iWinId = pm->iWinId;
      pmRet.iArg = err.iarg();
      pmRet.iTextSize = 0;
      emit outputMessage(fd, &pmRet);
      return;
    }
}
Esempio n. 5
0
PWidget *PukeController::id2pwidget(widgetId *pwi){ 
  PObject *obj = id2pobject(pwi);
  if(obj->widget()->isWidgetType())
    return (PWidget *) obj;
  else
    throw(errorNoSuchWidget(*pwi));
  return NULL;
}
Esempio n. 6
0
widgetId PukeController::createWidget(widgetId wI, PukeMessage *pm) 
{
  widgetId wIret;
  PWidget *parent = 0; // Defaults to no parent
  WidgetS *ws = new WidgetS;

  /*
   * The parent widget ID and type are packed into the iArg
   * the pattern is 2 shorts.
   */

  int iParent, iType;
  int found = sscanf(pm->cArg, "%d\t%d", &iParent, &iType);
  if(found != 2)
      throw(errorCommandFailed(PUKE_INVALID,7));

  wI.iWinId = iParent; // wI is the identifier for the parent widget

  if(widgetCF[iType] == NULL){ // No such widget, bail out.
    wIret.fd = 0;
    wIret.iWinId = 0;
    throw(errorCommandFailed(PUKE_INVALID,1));
  }

  uiBaseWinId++; // Get a new base win id

  // wIret holds the current widget id for the new widget
  wIret.iWinId = uiBaseWinId;
  wIret.fd = wI.fd;

  if(checkWidgetId(&wI) == TRUE){
    PObject *obj = WidgetList[wI.fd]->find(wI.iWinId)->pwidget;
    if(obj->widget()->isWidgetType() == FALSE){
      throw(errorCommandFailed(PUKE_INVALID, 0));
    }
    parent = (PWidget *) obj;
  }

  //  CreateArgs arg = CreateArgs(this, pm, &wIret, parent)
  CreateArgs arg(this, pm, &wIret, parent);
  ws->pwidget = (widgetCF[iType]->wc)(arg);
  if (ws->pwidget->hasError())
  {
    throw(errorCommandFailed(PUKE_INVALID, 0));
  }
  ws->type = iType;

  connect(ws->pwidget, SIGNAL(outputMessage(int, PukeMessage*)),
	  this, SIGNAL(outputMessage(int, PukeMessage*)));

  // insertPBoject(fd, uiBaseWinId, ws);
  // The widget list has to exist since we have ourselves in the list
  insertPObject(wIret.fd, wIret.iWinId, ws);
//  WidgetList[wIret.fd]->insert(wIret.iWinId, ws);
  return wIret;
}
Esempio n. 7
0
void
PTextViewBackend::AttachedToWindow(void)
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("AttachedToWindow");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BTextView::AttachedToWindow();
}
Esempio n. 8
0
void
PProgressBarBackend::Pulse()
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("Pulse");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BStatusBar::Pulse();
}
Esempio n. 9
0
void
PProgressBarBackend::DetachedFromWindow()
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("DetachedFromWindow");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BStatusBar::DetachedFromWindow();
}
Esempio n. 10
0
void
PRadioButtonBackend::DetachedFromWindow(void)
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("DetachedFromWindow");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BRadioButton::DetachedFromWindow();
}
Esempio n. 11
0
void
PLabelBackend::AllDetached(void)
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("AllDetached");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BStringView::AllDetached();
}
Esempio n. 12
0
void
PListViewBackend::AllAttached(void)
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("AllAttached");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BListView::AllAttached();
}
Esempio n. 13
0
void
PRadioButtonBackend::AllDetached(void)
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("AllDetached");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BRadioButton::AllDetached();
}
Esempio n. 14
0
void
PRadioButtonBackend::Pulse(void)
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("Pulse");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BRadioButton::Pulse();
}
Esempio n. 15
0
void
PListViewBackend::SelectionChanged(void)
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("SelectionChanged");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BListView::SelectionChanged();
}
Esempio n. 16
0
void
PListViewBackend::DetachedFromWindow(void)
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("DetachedFromWindow");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BListView::DetachedFromWindow();
}
Esempio n. 17
0
void
PListViewBackend::Pulse(void)
{
	PArgs in, out;
	EventData *data = fOwner->FindEvent("Pulse");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BListView::Pulse();
}
Esempio n. 18
0
void
PRadioButtonBackend::MakeFocus(bool param1)
{
	PArgs in, out;
	in.AddBool("focus", param1);
	EventData *data = fOwner->FindEvent("MakeFocus");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BRadioButton::MakeFocus(param1);
}
Esempio n. 19
0
void
PLabelBackend::DrawAfterChildren(BRect param1)
{
	PArgs in, out;
	in.AddRect("update", param1);
	EventData *data = fOwner->FindEvent("DrawAfterChildren");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BStringView::DrawAfterChildren(param1);
}
Esempio n. 20
0
void
PProgressBarBackend::MakeFocus(bool param1)
{
	PArgs in, out;
	in.AddBool("focus", param1);
	EventData *data = fOwner->FindEvent("MakeFocus");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BStatusBar::MakeFocus(param1);
}
Esempio n. 21
0
void
PProgressBarBackend::DrawAfterChildren(BRect param1)
{
	PArgs in, out;
	in.AddRect("update", param1);
	EventData *data = fOwner->FindEvent("DrawAfterChildren");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BStatusBar::DrawAfterChildren(param1);
}
Esempio n. 22
0
void
PRadioButtonBackend::DrawAfterChildren(BRect param1)
{
	PArgs in, out;
	in.AddRect("update", param1);
	EventData *data = fOwner->FindEvent("DrawAfterChildren");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BRadioButton::DrawAfterChildren(param1);
}
Esempio n. 23
0
void
PListViewBackend::Draw(BRect param1)
{
	PArgs in, out;
	in.AddRect("update", param1);
	EventData *data = fOwner->FindEvent("Draw");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BListView::Draw(param1);
}
Esempio n. 24
0
void
PLabelBackend::WindowActivated(bool param1)
{
	PArgs in, out;
	in.AddBool("active", param1);
	EventData *data = fOwner->FindEvent("WindowActivated");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BStringView::WindowActivated(param1);
}
Esempio n. 25
0
void
PRadioButtonBackend::MouseUp(BPoint param1)
{
	PArgs in, out;
	in.AddPoint("where", param1);
	EventData *data = fOwner->FindEvent("MouseUp");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BRadioButton::MouseUp(param1);
}
Esempio n. 26
0
void
PProgressBarBackend::WindowActivated(bool param1)
{
	PArgs in, out;
	in.AddBool("active", param1);
	EventData *data = fOwner->FindEvent("WindowActivated");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BStatusBar::WindowActivated(param1);
}
Esempio n. 27
0
void
PRadioButtonBackend::WindowActivated(bool param1)
{
	PArgs in, out;
	in.AddBool("active", param1);
	EventData *data = fOwner->FindEvent("WindowActivated");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BRadioButton::WindowActivated(param1);
}
Esempio n. 28
0
void
PProgressBarBackend::MouseUp(BPoint param1)
{
	PArgs in, out;
	in.AddPoint("where", param1);
	EventData *data = fOwner->FindEvent("MouseUp");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BStatusBar::MouseUp(param1);
}
Esempio n. 29
0
void
PListViewBackend::FrameMoved(BPoint param1)
{
	PArgs in, out;
	in.AddPoint("where", param1);
	EventData *data = fOwner->FindEvent("FrameMoved");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BListView::FrameMoved(param1);
}
Esempio n. 30
0
void
PTextViewBackend::MouseDown(BPoint param1)
{
	PArgs in, out;
	in.AddPoint("where", param1);
	EventData *data = fOwner->FindEvent("MouseDown");
	if (data->hook)
		fOwner->RunEvent(data, in, out);
	else
		BTextView::MouseDown(param1);
}