예제 #1
0
status_t
Attribute::Open(const char* name, int openMode, attr_cookie** _cookie)
{
	TRACE("Open\n");
	status_t status = CheckAccess(name, openMode);
	if (status < B_OK)
		return status;

	status = Find(name);
	if (status < B_OK)
		return status;

	attr_cookie* cookie = new(std::nothrow) attr_cookie;
	if (cookie == NULL)
		return B_NO_MEMORY;

	// initialize the cookie
	strlcpy(cookie->name, fName, B_ATTR_NAME_LENGTH);
	cookie->open_mode = openMode;
	cookie->create = false;

	// Should we truncate the attribute?
	if ((openMode & O_TRUNC) != 0)
		_Truncate();

	*_cookie = cookie;
	return B_OK;
}
예제 #2
0
status_t ChatSession::Say(const String16& statement)
{
	HRESULT hr = S_OK;
	String16 userName;
	int callerPid = GetCallerPID();
	_TRACE("ChatSession::Say(%s) >>",DISPLAY_STRING16(statement));	
	
	{
		Mutex::Autolock _lock(m_csAdviseLock);
		sp<IBinder> binder = m_Listeners.valueFor(callerPid);
		sp<IChatSessionEvents> eventSink = interface_cast<IChatSessionEvents>(binder);
		if(eventSink != NULL){
			_TRACE("**source(cse:%p  binder:%p) ",eventSink.get(),binder.get());
			userName  =  eventSink->GetUserName();
		}
	}

	if (userName.size() && CheckAccess(userName))
	{		
		{
			Mutex::Autolock _lock(m_csStatementLock);
			m_statements.add(userName + String16("\t:\t") +statement);
		}
		//Fire_OnNewStatement(userName, statement);
		ChatWorker::getInstance().Defer_OnNewStatement(this,userName, statement);
	}
	else
		hr = E_ACCESSDENIED;

	_TRACE("ChatSession::Say() <<hr:%x",hr);
	return hr;
}
예제 #3
0
HandleError HandleSystem::CloneHandle(Handle_t handle, Handle_t *newhandle, IdentityToken_t *newOwner, const HandleSecurity *pSecurity)
{
	HandleError err;
	QHandle *pHandle;
	unsigned int index;
	IdentityToken_t *ident = pSecurity ? pSecurity->pIdentity : NULL;

	if ((err=GetHandle(handle, ident, &pHandle, &index)) != HandleError_None)
	{
		return err;
	}

	/* Identities cannot be cloned */
	if (pHandle->set == HandleSet_Identity)
	{
		return HandleError_Identity;
	}

	/* Check if the handle can be cloned */
	if (!CheckAccess(pHandle, HandleAccess_Clone, pSecurity))
	{
		return HandleError_Access;
	}

	/* Make sure we're not cloning a clone */
	if (pHandle->clone)
	{
		QHandle *pParent = &m_Handles[pHandle->clone];
		return CloneHandle(pParent, pHandle->clone, newhandle, newOwner);
	}

	return CloneHandle(pHandle, index, newhandle, newOwner);
}
예제 #4
0
status_t
Attribute::Create(const char* name, type_code type, int openMode,
	attr_cookie** _cookie)
{
	status_t status = CheckAccess(name, openMode);
	if (status < B_OK)
		return status;

	attr_cookie* cookie = new(std::nothrow) attr_cookie;
	if (cookie == NULL)
		return B_NO_MEMORY;

	fName = name;

	// initialize the cookie
	strlcpy(cookie->name, fName, B_ATTR_NAME_LENGTH);
	cookie->type = type;
	cookie->open_mode = openMode;
	cookie->create = true;

	if (Find(name) == B_OK) {
		// attribute already exists
		if ((openMode & O_TRUNC) != 0)
			_Truncate();
	}
	*_cookie = cookie;
	return B_OK;
}
예제 #5
0
//
// Copies the working access spec to a spot in the application's test spec structure.
// (Saves the changes the user has made to the access spec.)
//
BOOL CAccessDialog::SaveList()
{
	int line_index;

	// Abort if we encounter an error.
	if (spec == NULL) {
		ErrorMessage("Unexpectedly found spec == NULL in CAccessDialog::SaveList()");
		CDialog::OnOK();
	}
	// Check to make sure the spec is filled in correctly.
	if (!CheckAccess())
		return FALSE;

	// Update the spec's name with the name edit box's contents.
	m_EName.GetWindowText(spec->name, MAX_WORKER_NAME);

	// Store the default assignment setting.
	spec->default_assignment = m_CDefaultAssignment.GetCurSel();

	// Fill in the access spec from the entries in the GUI list.
	for (line_index = 0; line_index < m_LAccess.GetItemCount(); line_index++) {
		item_being_changed = line_index;
		GetAll(&(spec->access[line_index]));
	}

	// If all the spec's lines have not been filled, mark
	// the last one as the end.
	if (line_index < MAX_ACCESS_SPECS)
		spec->access[line_index].of_size = IOERROR;

	// Indicate that the access was saved properly.
	return TRUE;
}
예제 #6
0
파일: HandleSys.cpp 프로젝트: asceth/synapi
HandleError HandleSystem::FreeHandle(Handle_t handle, const HandleSecurity *pSecurity)
{
    unsigned int index;
    QHandle *pHandle;
    HandleError err;
    IdentityToken_t *ident = pSecurity ? pSecurity->pIdentity : NULL;

    if ((err=GetHandle(handle, ident, &pHandle, &index)) != HandleError_None)
    {
        return err;
    }

    if (!CheckAccess(pHandle, HandleAccess_Delete, pSecurity))
    {
        return HandleError_Access;
    }

    if (pHandle->is_destroying)
    {
        /* Someone tried to free this recursively.
         * We'll just ignore this safely.
         */
        return HandleError_None;
    }

    return FreeHandle(pHandle, index);
}
예제 #7
0
bool IREGKEY::AccessAllowed( ACCESS_MASK required, ACCESS_MASK handle )
{
	return CheckAccess( required, handle,
						 KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS|KEY_NOTIFY,
						 KEY_SET_VALUE|KEY_CREATE_SUB_KEY|KEY_CREATE_LINK,
						 KEY_ALL_ACCESS );
}
예제 #8
0
bool COMPLETION_PORT_IMPL::AccessAllowed( ACCESS_MASK required, ACCESS_MASK handle )
{
	return CheckAccess( required, handle,
						 IO_COMPLETION_QUERY_STATE,
						 IO_COMPLETION_MODIFY_STATE,
						 IO_COMPLETION_ALL_ACCESS );
}
예제 #9
0
static bool
ProtoSetterImpl(JSContext *cx, CallArgs args)
{
    JS_ASSERT(TestProtoSetterThis(args.thisv()));

    const Value &thisv = args.thisv();
    if (thisv.isPrimitive()) {
        JS_ASSERT(!thisv.isNullOrUndefined());

        // Mutating a boxed primitive's [[Prototype]] has no side effects.
        args.rval().setUndefined();
        return true;
    }

    if (!cx->runningWithTrustedPrincipals())
        ++sSetProtoCalled;

    Rooted<JSObject*> obj(cx, &args.thisv().toObject());

    /* ES5 8.6.2 forbids changing [[Prototype]] if not [[Extensible]]. */
    if (!obj->isExtensible()) {
        obj->reportNotExtensible(cx);
        return false;
    }

    /*
     * Disallow mutating the [[Prototype]] of a proxy that wasn't simply
     * wrapping some other object.  Also disallow it on ArrayBuffer objects,
     * which due to their complicated delegate-object shenanigans can't easily
     * have a mutable [[Prototype]].
     */
    if (obj->isProxy() || obj->isArrayBuffer()) {
        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                             "Object", "__proto__ setter",
                             obj->isProxy() ? "Proxy" : "ArrayBuffer");
        return false;
    }

    /* Do nothing if __proto__ isn't being set to an object or null. */
    if (args.length() == 0 || !args[0].isObjectOrNull()) {
        args.rval().setUndefined();
        return true;
    }

    Rooted<JSObject*> newProto(cx, args[0].toObjectOrNull());

    unsigned dummy;
    Rooted<jsid> nid(cx, NameToId(cx->runtime->atomState.protoAtom));
    Rooted<Value> v(cx);
    if (!CheckAccess(cx, obj, nid, JSAccessMode(JSACC_PROTO | JSACC_WRITE), v.address(), &dummy))
        return false;

    if (!SetProto(cx, obj, newProto, true))
        return false;

    args.rval().setUndefined();
    return true;
}
예제 #10
0
// return 0 on success
unsigned int CNetServer::ValidatePass(unsigned int client)
{
  int nRes;
  unsigned int nSize;
  char * szLogin;
  char * szPass;
  char * szSalt;

// receive login 
  nRes = Recv(client, &nSize, sizeof(unsigned int)); 
  szLogin = (char *) malloc (nSize);
  nRes = Recv(client, szLogin, nSize); 

  showDebug(2, "client %d is %s\n", client, szLogin);

  szSalt = GetSalt(szLogin);
  if (!szSalt)
    szSalt = strdup("");
  nSize = strlen(szSalt)+1;

  nRes = Send(client, &nSize, sizeof(unsigned int));
  nRes = Send(client, szSalt, nSize);

// receive password
  nRes = Recv(client, &nSize, sizeof(unsigned int)); 
  szPass = (char *) malloc (nSize);
  nRes = Recv(client, szPass, nSize); 

  nRes = CheckAccess(g_bMustLogin, szLogin, szPass);
  showDebug(1, "return of checkaccess: %d\n", nRes);
  if (nRes)
    {
      Send(client, "nack", 5);
      Release(client);
    }
  else
    Send(client, " ack", 5);

  free(szPass);
  szPass = NULL;
  free(szLogin);
  szLogin = NULL;
  free(szSalt);
  szSalt = NULL;
  return nRes;
}
예제 #11
0
HandleError HandleSystem::ReadHandle(Handle_t handle, HandleType_t type, const HandleSecurity *pSecurity, void **object)
{
	unsigned int index;
	QHandle *pHandle;
	HandleError err;
	IdentityToken_t *ident = pSecurity ? pSecurity->pIdentity : NULL;

	if ((err=GetHandle(handle, ident, &pHandle, &index)) != HandleError_None)
	{
		return err;
	}

	if (!CheckAccess(pHandle, HandleAccess_Read, pSecurity))
	{
		return HandleError_Access;
	}

	/* Check the type inheritance */
	if (pHandle->type & HANDLESYS_SUBTYPE_MASK)
	{
		if (pHandle->type != type
			&& (TypeParent(pHandle->type) != TypeParent(type)))
		{
			return HandleError_Type;
		}
	} else if (type) {
		if (pHandle->type != type)
		{
			return HandleError_Type;
		}
	}

	if (object)
	{
		/* if we're a clone, the rules change - object is ONLY in our reference */
		if (pHandle->clone)
		{
			pHandle = &m_Handles[pHandle->clone];
		}
		*object = pHandle->object;
	}

	return HandleError_None;
}
예제 #12
0
HandleError HandleSystem::FreeHandle(Handle_t handle, const HandleSecurity *pSecurity)
{
	unsigned int index;
	QHandle *pHandle;
	HandleError err;
	IdentityToken_t *ident = pSecurity ? pSecurity->pIdentity : NULL;

	if ((err=GetHandle(handle, ident, &pHandle, &index)) != HandleError_None)
	{
		return err;
	}

	if (!CheckAccess(pHandle, HandleAccess_Delete, pSecurity))
	{
		return HandleError_Access;
	}

	return FreeHandle(pHandle, index);
}
예제 #13
0
static bool
ProtoGetterImpl(JSContext *cx, CallArgs args)
{
    JS_ASSERT(TestProtoGetterThis(args.thisv()));

    const Value &thisv = args.thisv();
    if (thisv.isPrimitive() && !BoxNonStrictThis(cx, args))
        return false;

    unsigned dummy;
    Rooted<JSObject*> obj(cx, &args.thisv().toObject());
    Rooted<jsid> nid(cx, NameToId(cx->runtime->atomState.protoAtom));
    Rooted<Value> v(cx);
    if (!CheckAccess(cx, obj, nid, JSACC_PROTO, v.address(), &dummy))
        return false;

    args.rval().set(v);
    return true;
}
예제 #14
0
파일: data.c 프로젝트: 3PO/vdr-plugin-sc
void cStructLoaderPlain::Load(bool reload)
{
  if(SL_TSTFLAG(SL_DISABLED) || reload) return;
  FILE *f=fopen(path,"r");
  if(f) {
    PreLoad();
    ListLock(true);
    SL_SETFLAG(SL_LOADED);
    PRINTF(L_GEN_INFO,"loading %s from %s",type,path);
    CheckAccess();
    int lineNum=0;
    char buff[4096];
    while(fgets(buff,sizeof(buff),f)) {
      lineNum++;
      if(!index(buff,'\n') && !feof(f)) {
        PRINTF(L_GEN_ERROR,"file %s readbuffer overflow line#%d",path,lineNum);
        SL_CLRFLAG(SL_LOADED);
        break;
        }
      strreplace(buff,'\n',0); strreplace(buff,'\r',0); // chomp
      bool hasContent=false;
      char *ls;
      for(ls=buff; *ls; ls++) {
        if(*ls==';' || *ls=='#') break;
        if(*ls>' ') hasContent=true;
        }
      if(hasContent) {
        *ls=0;
        if(!ParseLinePlain(skipspace(buff)))
          PRINTF(L_GEN_ERROR,"file %s has error in line #%d",path,lineNum);
        }
      }
    ListUnlock();
    PostLoad();
    fclose(f);
    LoadFinished();
    }
  else
    OpenFailed();
}
예제 #15
0
void ConCmdManager::InternalDispatch(const CCommand &command)
{
	int client = m_CmdClient;

	if (client)
	{
		CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
		if (!pPlayer || !pPlayer->IsConnected())
		{
			return;
		}
	}

	/**
	 * Note: Console commands will EITHER go through IServerGameDLL::ClientCommand,
	 * OR this dispatch.  They will NEVER go through both.
	 * -- 
	 * Whether or not it goes through the callback is determined by FCVAR_GAMEDLL
	 */
	const char *cmd = g_HL2.CurrentCommandName();

	ConCmdInfo *pInfo;
	if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
	{
        /* Unfortunately, we now have to do a slow lookup because Valve made client commands 
         * case-insensitive.  We can't even use our sortedness.
         */
        if (client == 0 && !engine->IsDedicatedServer())
        {
            return;
        }

        List<ConCmdInfo *>::iterator iter;

        pInfo = NULL;
        iter = m_CmdList.begin();
        while (iter != m_CmdList.end())
        {
            if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
            {
                pInfo = (*iter);
                break;
            }
            iter++;
        }
        
		if (pInfo == NULL)
        {
            return;
        }
	}

	/* This is a hack to prevent say triggers from firing on messages that were 
	 * blocked because of flooding.  We won't remove this, but the hack will get 
	 * "nicer" when we expose explicit say hooks.
	 */
	if (g_ChatTriggers.WasFloodedMessage())
	{
		return;
	}

	cell_t result = Pl_Continue;
	int args = command.ArgC() - 1;

	List<CmdHook *>::iterator iter;
	CmdHook *pHook;

	/* Execute server-only commands if viable */
	if (client == 0 && pInfo->srvhooks.size())
	{
		cell_t tempres = result;
		for (iter=pInfo->srvhooks.begin();
			 iter!=pInfo->srvhooks.end();
			 iter++)
		{
			pHook = (*iter);
			if (!pHook->pf->IsRunnable())
			{
				continue;
			}
			pHook->pf->PushCell(args);
			if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
			{
				if (tempres > result)
				{
					result = tempres;
				}
				if (result == Pl_Stop)
				{
					break;
				}
			}
		}
	
		/* Check if there's an early stop */
		if (result >= Pl_Stop)
		{
			if (!pInfo->sourceMod)
			{
				RETURN_META(MRES_SUPERCEDE);
			}
			return;
		}
	}

	/* Execute console commands */
	if (pInfo->conhooks.size())
	{
		cell_t tempres = result;
		for (iter=pInfo->conhooks.begin();
			iter!=pInfo->conhooks.end();
			iter++)
		{
			pHook = (*iter);
			if (!pHook->pf->IsRunnable())
			{
				continue;
			}
			if (client 
				&& pHook->pAdmin
				&& !CheckAccess(client, cmd, pHook->pAdmin))
			{
				if (result < Pl_Handled)
				{
					result = Pl_Handled;
				}
				continue;
			}

			/* On a listen server, sometimes the server host's client index can be set as 0.
			 * So index 1 is passed to the command callback to correct this potential problem.
			 */
			if (!engine->IsDedicatedServer())
			{
				client = g_Players.ListenClient();
			}

			pHook->pf->PushCell(client);
			pHook->pf->PushCell(args);

			if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
			{
				if (tempres > result)
				{
					result = tempres;
				}
				if (result == Pl_Stop)
				{
					break;
				}
			}
		}
	}

	if (result >= Pl_Handled)
	{
		if (!pInfo->sourceMod)
		{
			RETURN_META(MRES_SUPERCEDE);
		}
		return;
	}
}
예제 #16
0
SearchView::SearchView():
	ui::Window(ui::Point(0, 0), ui::Point(XRES+BARSIZE, YRES+MENUSIZE)),
	saveButtons(vector<ui::SaveButton*>()),
	errorLabel(NULL),
	c(NULL)
{

	Client::Ref().AddListener(this);

	nextButton = new ui::Button(ui::Point(XRES+BARSIZE-52, YRES+MENUSIZE-18), ui::Point(50, 16), "Next \x95");
	previousButton = new ui::Button(ui::Point(1, YRES+MENUSIZE-18), ui::Point(50, 16), "\x96 Prev");
	infoLabel  = new ui::Label(ui::Point(260, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-520, 16), "Page 1 of 1");
	tagsLabel  = new ui::Label(ui::Point(270, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-540, 16), "\boPopular Tags:");
	motdLabel  = new ui::RichLabel(ui::Point(51, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-102, 16), Client::Ref().GetMessageOfTheDay());

	class SearchAction : public ui::TextboxAction
	{
		SearchView * v;
	public:
		SearchAction(SearchView * _v) { v = _v; }
		void TextChangedCallback(ui::Textbox * sender)
		{
			v->doSearch();
		}
	};
	searchField = new ui::Textbox(ui::Point(60, 10), ui::Point((XRES+BARSIZE)-238, 17), "", "[search]");
	searchField->Appearance.icon = IconSearch;
	searchField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	searchField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	searchField->SetActionCallback(new SearchAction(this));


	class SortAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		SortAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->ChangeSort();
		}
	};
	sortButton = new ui::Button(ui::Point(XRES+BARSIZE-140, 10), ui::Point(61, 17), "Sort");
	sortButton->SetIcon(IconVoteSort);
	sortButton->SetTogglable(true);
	sortButton->SetActionCallback(new SortAction(this));
	sortButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
	sortButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(sortButton);

	class MyOwnAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		MyOwnAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->ShowOwn(sender->GetToggleState());
		}
	};
	ownButton = new ui::Button(ui::Point(XRES+BARSIZE-70, 10), ui::Point(61, 17), "My Own");
	ownButton->SetIcon(IconMyOwn);
	ownButton->SetTogglable(true);
	ownButton->SetActionCallback(new MyOwnAction(this));
	ownButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
	ownButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(ownButton);

	class FavAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		FavAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->ShowFavourite(sender->GetToggleState());
		}
	};
	favButton = new ui::Button(searchField->Position+ui::Point(searchField->Size.X+15, 0), ui::Point(17, 17), "");
	favButton->SetIcon(IconFavourite);
	favButton->SetTogglable(true);
	favButton->Appearance.Margin.Left+=2;
	favButton->SetActionCallback(new FavAction(this));
	favButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
	favButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	favButton->Appearance.BorderInactive = ui::Colour(170,170,170);
	AddComponent(favButton);
	
	class ClearSearchAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		ClearSearchAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->clearSearch();
		}
	};
	ui::Button * clearSearchButton = new ui::Button(searchField->Position+ui::Point(searchField->Size.X-1, 0), ui::Point(17, 17), "");
	clearSearchButton->SetIcon(IconClose);
	clearSearchButton->SetActionCallback(new ClearSearchAction(this));
	clearSearchButton->Appearance.Margin.Left+=2;
	clearSearchButton->Appearance.Margin.Top+=2;
	clearSearchButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
	clearSearchButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	clearSearchButton->Appearance.BorderInactive = ui::Colour(170,170,170);
	AddComponent(clearSearchButton);

	class NextPageAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		NextPageAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->NextPage();
		}
	};
	nextButton->SetActionCallback(new NextPageAction(this));
	nextButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
	nextButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	class PrevPageAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		PrevPageAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->PrevPage();
		}
	};
	previousButton->SetActionCallback(new PrevPageAction(this));
	previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	previousButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(nextButton);
	AddComponent(previousButton);
	AddComponent(searchField);
	AddComponent(infoLabel);

	loadingSpinner = new ui::Spinner(ui::Point(((XRES+BARSIZE)/2)-12, ((YRES+MENUSIZE)/2)+12), ui::Point(24, 24));
	AddComponent(loadingSpinner);

	ui::Label * searchPrompt = new ui::Label(ui::Point(10, 10), ui::Point(50, 16), "Search:");
	searchPrompt->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	searchPrompt->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(searchPrompt);

	class RemoveSelectedAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		RemoveSelectedAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->RemoveSelected();
		}
	};

	class UnpublishSelectedAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		UnpublishSelectedAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->UnpublishSelected();
		}
	};

	class FavouriteSelectedAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		FavouriteSelectedAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->FavouriteSelected();
		}
	};

	class ClearSelectionAction : public ui::ButtonAction
	{
		SearchView * v;
	public:
		ClearSelectionAction(SearchView * _v) { v = _v; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->ClearSelection();
		}
	};

	removeSelected = new ui::Button(ui::Point((((XRES+BARSIZE)-415)/2), YRES+MENUSIZE-18), ui::Point(100, 16), "Delete");
	removeSelected->Visible = false;
	removeSelected->SetActionCallback(new RemoveSelectedAction(this));
	AddComponent(removeSelected);

	unpublishSelected = new ui::Button(ui::Point((((XRES+BARSIZE)-415)/2)+105, YRES+MENUSIZE-18), ui::Point(100, 16), "Unpublish");
	unpublishSelected->Visible = false;
	unpublishSelected->SetActionCallback(new UnpublishSelectedAction(this));
	AddComponent(unpublishSelected);

	favouriteSelected = new ui::Button(ui::Point((((XRES+BARSIZE)-415)/2)+210, YRES+MENUSIZE-18), ui::Point(100, 16), "Favourite");
	favouriteSelected->Visible = false;
	favouriteSelected->SetActionCallback(new FavouriteSelectedAction(this));
	AddComponent(favouriteSelected);

	clearSelection = new ui::Button(ui::Point((((XRES+BARSIZE)-415)/2)+315, YRES+MENUSIZE-18), ui::Point(100, 16), "Clear selection");
	clearSelection->Visible = false;
	clearSelection->SetActionCallback(new ClearSelectionAction(this));
	AddComponent(clearSelection);

	CheckAccess();
}
예제 #17
0
파일: data.c 프로젝트: 3PO/vdr-plugin-sc
void cStructLoader::Load(bool reload)
{
  if(SL_TSTFLAG(SL_DISABLED) || (reload && !SL_TSTFLAG(SL_WATCH))) return;
  FILE *f=fopen(path,"r");
  if(f) {
    PreLoad();
    int curr_mtime=MTime(true);
    ListLock(true);
    bool doload=false;
    if(!reload) {
      Clear(); Modified(false);
      mtime=curr_mtime;
      doload=true;
      }
    else if(mtime<curr_mtime) {
      PRINTF(L_CORE_LOAD,"detected change of %s",path);
      if(IsModified())
        PRINTF(L_CORE_LOAD,"discarding in-memory changes");
      for(cStructItem *a=First(); a; a=Next(a)) DelItem(a);
      Modified(false);
      mtime=curr_mtime;
      doload=true;
      }
    if(doload) {
      SL_SETFLAG(SL_LOADED);
      PRINTF(L_GEN_INFO,"loading %s from %s",type,path);
      CheckAccess();
      int lineNum=0, num=0;
      char buff[4096];
      while(fgets(buff,sizeof(buff),f)) {
        lineNum++;
        if(!index(buff,'\n') && !feof(f)) {
          PRINTF(L_GEN_ERROR,"file %s readbuffer overflow line#%d",path,lineNum);
          SL_CLRFLAG(SL_LOADED);
          break;
          }
        strreplace(buff,'\n',0); strreplace(buff,'\r',0); // chomp
        bool hasContent=false;
        char *ls;
        for(ls=buff; *ls; ls++) {
          if(*ls==';' || *ls=='#') {		  // comment
            if(hasContent)
              while(ls>buff && ls[-1]<=' ') ls--; // search back to non-whitespace
            break;
            }
          if(*ls>' ') hasContent=true;		  // line contains something usefull
          }
        cStructItem *it=0;
        if(hasContent) {
          char save=*ls;
          *ls=0; it=ParseLine(skipspace(buff)); *ls=save;
          if(!it) {
            PRINTF(L_GEN_ERROR,"file %s has error in line #%d",path,lineNum);
            ls=buff;
            }
          else num++;
          }
        else ls=buff;
        if(!it) it=new cCommentItem;
        if(it) {
          it->SetComment(ls);
          Add(it);
          }
        else {
          PRINTF(L_GEN_ERROR,"out of memory loading file %s",path);
          SL_CLRFLAG(SL_LOADED);
          break;
          }
        }
      ListUnlock();
      PRINTF(L_CORE_LOAD,"loaded %d %s from %s",num,type,path);
      PostLoad();
      }
    else ListUnlock();

    fclose(f);
    LoadFinished();
    }
  else
    OpenFailed();
}
예제 #18
0
파일: Access.cpp 프로젝트: slaakko/cmajor
void CheckAccess(Cm::Sym::Symbol* fromSymbol, const Span& fromSpan, Cm::Sym::Symbol* toSymbol)
{
    if (!fromSymbol || !toSymbol) return;
    Cm::Sym::FunctionSymbol* toContainingFunction = toSymbol->ContainingFunction();
    if (toContainingFunction)
    {
        Cm::Sym::FunctionSymbol* fromFunction = fromSymbol->Function();
        if (fromFunction == toContainingFunction)
        {
            return;
        }
    }
    if (fromSymbol->IsFunctionSymbol())
    {
        Cm::Sym::FunctionSymbol* fromFun = static_cast<Cm::Sym::FunctionSymbol*>(fromSymbol);
        if (fromFun->IsFunctionTemplateSpecialization())
        {
            return;
        }
        if (fromFun->IsMemberOfTemplateType())
        {
            return;
        }
    }
    Cm::Sym::ClassTypeSymbol* toContainingClass = toSymbol->ContainingClass();
    if (toContainingClass)
    {
        CheckAccess(fromSymbol, fromSpan, toContainingClass);
    }
    switch (toSymbol->DeclaredAccess())
    {
        case Cm::Sym::SymbolAccess::public_:
        {
            return;
        }
        case Cm::Sym::SymbolAccess::protected_:
        {
            Cm::Sym::ClassTypeSymbol* fromContainingClass = fromSymbol->ContainingClass();
            if (fromContainingClass)
            {
                if (toContainingClass->IsSameParentOrAncestorOf(fromContainingClass))
                {
                    return;
                }
                if (fromContainingClass->HasBaseClass(toContainingClass))
                {
                    return;
                }
            }
            break;
        }
        case Cm::Sym::SymbolAccess::internal_:
        {
            return;
        }
        case Cm::Sym::SymbolAccess::private_:
        {
            if (toContainingClass)
            {
                Cm::Sym::ClassTypeSymbol* fromContainingClass = fromSymbol->ContainingClass();
                if (toContainingClass->IsSameParentOrAncestorOf(fromContainingClass))
                {
                    return;
                }
            }
            break;
        }
    }
    Span span = fromSpan.Valid() ? fromSpan : fromSymbol->GetSpan();
    throw Cm::Core::Exception(toSymbol->TypeString() + " '" + toSymbol->FullName() + "' is inaccessible due to its protection level", span, toSymbol->GetSpan());
}
예제 #19
0
ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type)
{
	ConCmdInfo *pInfo;

	if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
	{
		List<ConCmdInfo *>::iterator iter;

		pInfo = NULL;
		iter = m_CmdList.begin();
		while (iter != m_CmdList.end())
		{
			if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
			{
				pInfo = (*iter);
				break;
			}
			iter++;
		}

		if (pInfo == NULL)
		{
			return type;
		}
	}

	cell_t result = type;
	cell_t tempres = result;
	List<CmdHook *>::iterator iter;
	CmdHook *pHook;
	for (iter=pInfo->conhooks.begin();
		 iter!=pInfo->conhooks.end();
		 iter++)
	{
		pHook = (*iter);
		if (!pHook->pf->IsRunnable())
		{
			continue;
		}
		if (pHook->pAdmin && !CheckAccess(client, cmd, pHook->pAdmin))
		{
			if (result < Pl_Handled)
			{
				result = Pl_Handled;
			}
			continue;
		}
		pHook->pf->PushCell(client);
		pHook->pf->PushCell(args);
		if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
		{
			if (tempres > result)
			{
				result = tempres;
			}
			if (result == Pl_Stop)
			{
				break;
			}
		}
	}

	type = (ResultType)result;

	return type;
}
예제 #20
0
void SearchView::NotifyAuthUserChanged(Client * sender)
{
	CheckAccess();
}
예제 #21
0
/*****************************************************************************
  TryToChangeDir
  INPUT:
  OUTPUT:
  DESCRIPTION:
    This function is used both by the ChangeDir dialog, and the FileMgr
    dialog's text field; it attempts to verify the incoming string, and
    then change to the indicated directory.
  NOTE:
 *****************************************************************************/
static Boolean
TryToChangeDir(
       Boolean isFromDialog,
       char * incoming_string,
       FileMgrData * file_mgr_data,
       FileMgrRec * file_mgr_rec,
       ChangeDirData * change_dir_data,
       Widget selection_box,
       ChangeDirApply * apply_data,
       XmSelectionBoxCallbackStruct * callback_data,
       void (*callback)())
{
  char * new_directory;
  char * host;
  char * path;
  struct stat stat_buf;
  Widget list;
  XmString path_string;
  XmString host_string;
  Arg args[1];
  char * message_buf;
  char * tmpStr;
  char * title;
  char * msg;
  Boolean rc = True;
  char *restricted = NULL;

  new_directory = XtNewString(incoming_string);

  if ((new_directory) && (strcmp(new_directory, "") != 0))
  {
     _DtPathFromInput(new_directory, file_mgr_data->current_directory,
                      &host, &path);
  }
  else
  {
     tmpStr = GetSharedMessage(CHANGE_DIR_ERROR_TITLE);
     title = XtNewString(tmpStr);
     tmpStr = GETMESSAGE(2,18, "Destination Folder name is missing.\nType in a folder name or select a folder from the list.");
     msg = XtNewString(tmpStr);

     if(isFromDialog)
       _DtMessage(selection_box, title, msg, NULL, HelpRequestCB);
     else
       _DtMessage(file_mgr_rec->current_directory_text, title, msg, NULL,
                  HelpRequestCB);

     XtFree(title);
     XtFree(msg);
     return False;
  }


   /* Don't allow access to the desktop directory */
   if (path)
   {
      char *ttpath = (char *) GetTTPath(path);
      char *dtpath = (char *) GetTTPath(desktop_dir);
      if( ttpath && strcmp(ttpath, dtpath) == 0)
      {
        restricted = ttpath;
        XtFree(path);
        path = NULL;
      }
   }

   /* Stat the file and see if it is a valid directory.  (If the current view
      is restricted, make sure that the new directory doesn't violate the
      directory restrictions. If so, refilter the displayed file set to show
      the files in this directory.
   */
   if ((path)
       &&(stat(path, &stat_buf) == 0)
       &&((stat_buf.st_mode & S_IFMT) == S_IFDIR)
       &&(CheckRestrictedDir(file_mgr_rec, file_mgr_data, &path, False) == 0))
   {
     /* Check for read/xcute permission */
     if (CheckAccess(path, R_OK | X_OK))
     {
       tmpStr = GETMESSAGE(9, 6, "Action Error");
       title = XtNewString(tmpStr);
       msg = (char *)XtMalloc(strlen(GETMESSAGE(30, 1, "Cannot read from %s"))
                            + strlen(new_directory)
                            + 1);
       sprintf(msg, GETMESSAGE(30, 1, "Cannot read from %s"), new_directory);

       if(isFromDialog)
         _DtMessage(selection_box, title, msg, NULL, HelpRequestCB);
       else
         _DtMessage(file_mgr_rec->current_directory_text, title,
                    msg, NULL, HelpRequestCB);

       XtFree(title);
       XtFree(msg);
       return;
     }
     else
     {
       if (selection_box)
       {
         /* Adjust the selection box elements to add the text item
          into the list.
         */
         list = XmSelectionBoxGetChild(selection_box, XmDIALOG_LIST);

         path_string = XmStringCreateLocalized(path);

         if (XmListItemExists(list, path_string))
           XmListDeselectAllItems(list);
         else
           XmListAddItem(list, path_string, 0);

         XmListSelectItem(list, path_string, False);
         XmListSetBottomPos(list, 0);

         XmStringFree(path_string);
       }

       /*  Clear out the text string  */
       if (isFromDialog)
       {
         if(restrictMode)
           XtSetArg(args[0],
                    XmNtextString,
                    XmStringCreateLocalized(users_home_dir));
         else
           XtSetArg(args[0], XmNtextString, NULL);
         XtSetValues(selection_box, args, 1);
       }
       else
       {
         if(!file_mgr_data || !file_mgr_data->restricted_directory)
           XmTextFieldSetString(file_mgr_rec->current_directory_text,
                              incoming_string);

       }


       /* Update the change directory host name field
          and the host name indicator widget in the dialog.
       */
       XtFree((char *) change_dir_data->host_name);
       change_dir_data->host_name = XtNewString(host);

       if (selection_box)
       {
         tmpStr = GETMESSAGE(2, 16, "System Name: ");
         message_buf = XtMalloc(strlen(tmpStr) +
                                strlen(change_dir_data->host_name) + 1);
         sprintf(message_buf, "%s%s", tmpStr, change_dir_data->host_name);
         host_string =
           XmStringCreateLocalized(message_buf);
         XtSetArg(args[0], XmNlabelString, host_string);
         XtSetValues(XmSelectionBoxGetChild(selection_box,XmDIALOG_LIST_LABEL),
                     args, 1);
         XtFree(message_buf);
         XmStringFree(host_string);

         XmUpdateDisplay (selection_box);
       }

       /*  Call the encapsulation change data callback  */
       if (isFromDialog)
         (*callback)(selection_box, apply_data->client_data, path);
       else
         (*callback)(file_mgr_data, path);
     }
   }
   else
   {
     tmpStr = GetSharedMessage(CHANGE_DIR_ERROR_TITLE);
     title = XtNewString(tmpStr);
     if(restricted)
     {
       tmpStr = GETMESSAGE(2,20,"You cannot switch to folder:\n\n%s\n\nYou are not allowed to view  this folder\nbecause it is a restricted folder.");
       path = restricted;
     }
     else
       tmpStr = GETMESSAGE(2,19,"The following folder name is invalid.\n\n%s");
     if(path)
     {
       message_buf = XtMalloc(strlen(tmpStr) + strlen(path) + 1);
       sprintf(message_buf, tmpStr, path);
     }
     else
     {
       message_buf = XtMalloc(strlen(tmpStr) + strlen(new_directory) + 1);
       sprintf(message_buf, tmpStr, new_directory);
     }

     if (isFromDialog)
       _DtMessage(selection_box, title, message_buf, NULL, HelpRequestCB);
     else
       _DtMessage(file_mgr_rec->current_directory_text, title, message_buf,
                  NULL, HelpRequestCB);

     XtFree(title);
     XtFree(message_buf);
     rc = False;
   }

   if (path)
      XtFree((char *) path);
   XtFree((char *) host);
   XtFree((char *) new_directory);

   return rc;
}