Example #1
0
GaduDriveSendTicketRequest *GaduDriveService::requestSendTicket(QString recipient, QString fileName, qint64 fileSize)
{
    auto sendTicketRequest = new GaduDriveSendTicketRequest{
        recipient, fileName, fileSize, m_sessionToken, m_networkAccessManager.get(), this};

    if (!m_sessionToken.isValid())
    {
        if (!m_authorization)
        {
            m_authorization =
                new GaduDriveAuthorization{account().id(), m_imTokenService->imToken(),
                                           m_versionService->nameWithVersion(), m_networkAccessManager.get(), this};
            connect(
                m_authorization.get(), SIGNAL(authorized(GaduDriveSessionToken)), this,
                SLOT(authorized(GaduDriveSessionToken)));
            m_authorization->authorize();
        }

        connect(
            m_authorization.get(), SIGNAL(authorized(GaduDriveSessionToken)), sendTicketRequest,
            SLOT(authorized(GaduDriveSessionToken)));
    }

    return sendTicketRequest;
}
Example #2
0
void OAuthManager::authorize(OAuthConsumer consumer)
{
	OAuthAuthorizationChain *chain = new OAuthAuthorizationChain(consumer, NetworkManager, this);
	chain->setRequestTokenUrl("http://api.gadu-gadu.pl/request_token");
	chain->setAuthorizeUrl("https://login.gadu-gadu.pl/authorize");
	chain->setAuthorizeCallbackUrl("http://www.mojageneracja.pl");
	chain->setAccessTokenUrl("http://api.gadu-gadu.pl/access_token");

	connect(chain, SIGNAL(authorized(OAuthToken)), this, SIGNAL(authorized(OAuthToken)));
	chain->authorize();
}
Example #3
0
void KActionPrivate::init(KAction *q_ptr)
{
    q = q_ptr;

    QObject::connect(q, SIGNAL(triggered(bool)), q, SLOT(slotTriggered()));

    q->setProperty("isShortcutConfigurable", true);

    decorator = new KAuth::ObjectDecorator(q);
    QObject::connect(decorator, SIGNAL(authorized(KAuth::Action)),
                     q, SIGNAL(authorized(KAuth::Action)));
    QObject::connect(KGlobalAccel::self(), SIGNAL(globalShortcutChanged(QAction*,QKeySequence)),
                     q, SLOT(_k_emitActionGlobalShortcutChanged(QAction*,QKeySequence)));
}
Example #4
0
void 
destruct_xml()
{
	if(authorized()) {
		dest("data/cdata");
		dest("data/characterdata");
		dest("data/element");
		dest("data/fragment");
		dest("data/comment");
		dest("data/root");
		dest("data/pi");
	}

	dest("lib/std/attributes");
	dest("lib/std/serialize");
	dest("lib/std/tag");
	dest("lib/std/parse");
	
	dest("lib/file");
	dest("lib/string");
	dest("lib/log");
	dest("lib/dom_info");

	/*dest("example/testing");*/
	
	/* This file */
	call_out("dest", 0, "lib/reload");
}
Example #5
0
void do_makeclan( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *rch;
    CLAN_DATA *clan;
    char       filename [ MAX_STRING_LENGTH ];
    char       who_name [ MAX_STRING_LENGTH ];

    rch = get_char( ch );

    if ( !authorized( rch, "makeclan" ) )
        return;

    if ( argument[0] == '\0' )
    {
        send_to_char( "Syntax: makeclan <clan name>\n\r", ch );
        return;
    }

    one_argument( argument, who_name );
    who_name[14] = '\0';

    sprintf( filename, "%s.cln", who_name );

    clan = (CLAN_DATA *) alloc_mem ( sizeof( CLAN_DATA ) );
    if ( !clan_first )
	clan_first		= clan;
    else
	clan_last->next		= clan;
	clan->next		= NULL;
	clan_last		= clan;

    clan->filename		= str_dup( filename );
    clan->who_name		= str_dup( who_name );
    clan->name			= str_dup( argument );
    clan->motto			= str_dup( "" );
    clan->description		= str_dup( "" );
    clan->overlord		= str_dup( "" );
    clan->chieftain		= str_dup( "" );
    clan->subchiefs		= 0;
    clan->clanheros		= 0;
    clan->members		= 0;
    clan->recall		= 3001;
    clan->donation		= 0;
    clan->cclass		= 0;
    clan->mkills		= 0;
    clan->mdeaths		= 0;
    clan->pkills		= 0;
    clan->pdeaths		= 0;
    clan->illegal_pk		= 0;
    clan->score			= 0;
    clan->clan_type		= 0;
    clan->clanobj1		= 0;
    clan->clanobj2		= 0;
    clan->clanobj3		= 0;

    return;
}
kern_return_t
do_LKDCHelperExit (__unused mach_port_t port, audit_token_t token)
{
	if (!authorized(token))
		goto fin;
	helplog(ASL_LEVEL_NOTICE, "Idle exit");
	exit(0);

fin:
	return KERN_SUCCESS;
}
Example #7
0
void do_immtalk( CHAR_DATA *ch, const char *argument )
{
    CHAR_DATA *rch;

    rch = get_char( ch );

    if ( !authorized( rch, "immtalk" ) )
        return;

    talk_channel( ch, argument, CHANNEL_IMMTALK, "immtalk" );
    return;
}
Example #8
0
void TwitterInterface::onAccessTokenReceived (const QString& token, const QString& tokenSecret)
{
#ifdef WP_DEBUG
    qDebug () << Q_FUNC_INFO << "Access tokens now stored. You are ready to send Tweets from user's account!";
#endif
    this->Token_ = token;
    this->TokenSecret_ = tokenSecret;


    emit authorized (token, tokenSecret);

}
Example #9
0
 void
 authorizeResponse(bool ok, const string& reason)
 {
     if(ok)
     {
         authorized(_sessionRouter->_sslSessionManager);
     }
     else
     {
         exception(PermissionDeniedException(reason.empty() ? string("permission denied") : reason));
     }
 }
Example #10
0
papi_status_t
hold_release_job(papi_service_t handle, char *printer,
		int32_t job_id, int flag)
{
	papi_status_t status;
	service_t *svc = handle;
	REQUEST *r = NULL;
	char *file;
	char *dest;

	if ((svc == NULL) || (printer == NULL) || (job_id < 0))
		return (PAPI_BAD_ARGUMENT);

	if ((status = authorized(svc, job_id)) != PAPI_OK)
		return (status);

	dest = printer_name_from_uri_id(printer, job_id);
	status = lpsched_start_change(svc, dest, job_id, &file);
	if (status != PAPI_OK)
		return (status);

	if ((r = getrequest(file)) != NULL) {
		r->actions &= ~ACT_RESUME;
		switch (flag) {
		case 0:
			r->actions |= ACT_HOLD;
			break;
		case 1:
			r->actions |= ACT_RESUME;
			break;
		case 2:
			r->actions |= ACT_IMMEDIATE;
			break;
		}
		if (putrequest(file, r) < 0) {
			detailed_error(svc,
			    gettext("failed to write job: %s: %s"),
			    file, strerror(errno));
			freerequest(r);
			return (PAPI_DEVICE_ERROR);
		}
		freerequest(r);
	} else {
		detailed_error(svc, gettext("failed to read job: %s: %s"),
		    file, strerror(errno));
		return (PAPI_DEVICE_ERROR);
	}

	status = lpsched_end_change(svc, dest, job_id);

	return (status);
}
void ModuleView::stateChanged()
{
    KCModuleProxy * activeModule = d->mPages.value( d->mPageWidget->currentPage() );
    KAuth::Action moduleAction;
    bool change = false;
    if( activeModule ) {
        change = activeModule->changed();

        disconnect( d->mApplyAuthorize, SIGNAL(authorized(KAuth::Action)), this, SLOT(moduleSave()) );
        disconnect( d->mApply, SIGNAL(clicked()), this, SLOT(moduleSave()) );
        if( activeModule->realModule()->authAction().isValid() ) {
            connect( d->mApplyAuthorize, SIGNAL(authorized(KAuth::Action)), this, SLOT(moduleSave()) );
            moduleAction = activeModule->realModule()->authAction();
        } else {
            connect( d->mApply, SIGNAL(clicked()), this, SLOT(moduleSave()) );
        }
    }

    updatePageIconHeader( d->mPageWidget->currentPage() );
    d->mApplyAuthorize->setAuthAction( moduleAction );
    d->mApply->setEnabled( change );
    d->mReset->setEnabled( change );
    emit moduleChanged( change );
}
Example #12
0
void do_memory( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *rch;
    char       buf [ MAX_STRING_LENGTH ];

    rch = get_char( ch );
    
    if ( authorized( rch, "memory" ) )
    {
      sprintf( buf, "Structure  |        Allocated     |     In Active Use\n\r"); send_to_char(C_DEFAULT, buf, ch);
      sprintf( buf, "Affects          %5d                    %5d\n\r", top_alloc_affect, top_affect    ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Areas            %5d                    %5d\n\r", top_alloc_area, top_area      ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "ExDes            %5d                    %5d\n\r", top_alloc_extra_descr, top_extra_descr ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Exits            %5d                    %5d\n\r", top_alloc_exit, top_exit      ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Helps            %5d                    %5d\n\r", top_alloc_help, top_help      ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Characters       %5d                    %5d\n\r", top_alloc_char, top_char ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Mob Index        %5d                    %5d\n\r", top_alloc_mob_index, top_mob_index ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Objs             %5d                    %5d\n\r", top_alloc_obj, top_obj ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Obj Index        %5d                    %5d\n\r", top_alloc_obj_index, top_obj_index ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Resets           %5d                    %5d\n\r", top_alloc_reset, top_reset     ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Rooms            %5d                    %5d\n\r", top_alloc_room_index, top_room_index      ); send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Shops            %5d                    %5d\n\r", top_alloc_shop, top_shop      ); send_to_char(C_DEFAULT, buf, ch );

      /*
      sprintf( buf, "Strings %5d strings of %7d bytes (max %d).\n\r",
	      nAllocString, sAllocString, MAX_STRING );
      send_to_char(C_DEFAULT, buf, ch );

      sprintf( buf, "Perms   %5d blocks of %7d bytes.  Max %7d bytes.\n\r",
	      nAllocPerm, sAllocPerm, 10*1024*1024 );
      send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "%3d%% of max used.\n\r", (sAllocPerm*10) / (1024*1024) );
      send_to_char(C_DEFAULT, buf, ch );
      sprintf( buf, "Mem used: %d bytes of %d max.\n\r",
	     sAllocPerm, 10*1024*1024 );
      sprintf( buf + strlen(buf), "%3d%% of max used.\n\r",
	     (sAllocPerm*10) / (1024*1024) );
      send_to_char(C_DEFAULT, buf, ch );
      */
      return;
    }

    else
    {
    send_to_char(C_DEFAULT, "You are not authorized to use the memory command.\r\n", ch );
    return;
    }
}
kern_return_t
do_LKDCSetLogLevel (__unused mach_port_t port, int logLevel, audit_token_t token)
{
	int				error = 0;
	
	LKDCLogEnter ();
	
	if (!authorized(token))
		goto fin;
	
	LKDCLogLevel = logLevel;
	
fin:
	LKDCLogExit (error);
	return KERN_SUCCESS;
}
Example #14
0
papi_status_t
papiJobCancel(papi_service_t handle, char *printer, int32_t job_id)
{
	papi_status_t result = PAPI_OK;
	service_t *svc = handle;
	char req_id[64];
	char *dest;
	char *user = NULL;

	if ((svc == NULL) || (printer == NULL) || (job_id < 0))
		return (PAPI_BAD_ARGUMENT);

	dest = printer_name_from_uri_id(printer, job_id);
	snprintf(req_id, sizeof (req_id), "%s-%d", dest, job_id);
	free(dest);

	if (papiAttributeListGetString(svc->attributes, NULL, "user-name",
	    &user) == PAPI_OK) {
		REQUEST *r = getrequest(req_id);

		if ((result = authorized(handle, job_id)) != PAPI_OK)
			result = PAPI_NOT_AUTHORIZED;

		if ((r != NULL) && (r->user != NULL) &&
		    (strcmp(r->user, user) != 0))
			result = PAPI_NOT_AUTHORIZED;
		freerequest(r);
	}

	if (result == PAPI_OK) {
		short status = MOK;

		if ((snd_msg(svc, S_CANCEL_REQUEST, req_id) < 0) ||
		    (rcv_msg(svc, R_CANCEL_REQUEST, &status) < 0))
			status = MTRANSMITERR;

		result = lpsched_status_to_papi_status(status);
	}

	return (result);
}
kern_return_t
do_LKDCFindKDCForRealm (__unused mach_port_t port, 
						realmNameIn_t realm,
						hostnameOut_t hostname,
						int *kdcport,
						int *err,
						audit_token_t token)
{
	LKDCLocator    *lkdc;
	int				error = 0;

	LKDCLogEnter ();

	*kdcport = 0;
	hostname[0] = '\0';

	if (!authorized(token)) {
		error = kLKDCHelperNotAuthorized;
		goto fin;
	}
	
	LKDCLog ("Looking up host for %s", realm);

	error = LKDCHostnameForRealm (realm, &lkdc);
	
	if (0 != error || NULL == lkdc->serviceHost) {
		goto fin;
	}
	
	strlcpy (hostname, lkdc->serviceHost, sizeof (hostnameOut_t));
	*kdcport = lkdc->servicePort;

fin:
	update_idle_timer();
	
	*err = error;
	LKDCLogExit (error);
	
	return KERN_SUCCESS;
}
kern_return_t
do_LKDCDumpStatus (__unused mach_port_t port, int logLevel, audit_token_t token)
{
	int				error = 0;
	int				savedLogLevel;

	LKDCLogEnter ();

	if (!authorized(token))
		goto fin;

	savedLogLevel = LKDCLogLevel;
	LKDCLogLevel = logLevel;
	
	LKDCDumpCacheStatus ();

	LKDCLogLevel = savedLogLevel;

fin:
	LKDCLogExit (error);
	return KERN_SUCCESS;
}
// Tests that an agent endpoint handler forms
// correct queries against the authorizer.
TEST_P(SlaveEndpointTest, AuthorizedRequest)
{
  const string endpoint = GetParam();

  StandaloneMasterDetector detector;

  MockAuthorizer mockAuthorizer;

  Try<Owned<cluster::Slave>> agent = StartSlave(&detector, &mockAuthorizer);
  ASSERT_SOME(agent);

  Future<authorization::Request> request;
  EXPECT_CALL(mockAuthorizer, authorized(_))
    .WillOnce(DoAll(FutureArg<0>(&request),
                    Return(true)));

  Future<Response> response = http::get(
      agent.get()->pid,
      endpoint,
      None(),
      createBasicAuthHeaders(DEFAULT_CREDENTIAL));

  AWAIT_READY(request);

  const string principal = DEFAULT_CREDENTIAL.principal();
  EXPECT_EQ(principal, request.get().subject().value());

  // TODO(bbannier): Once agent endpoint handlers use more than just
  // `GET_ENDPOINT_WITH_PATH` we should factor out the request method
  // and expected authorization action and parameterize
  // `SlaveEndpointTest` on that as well in addition to the endpoint.
  EXPECT_EQ(authorization::GET_ENDPOINT_WITH_PATH, request.get().action());

  EXPECT_EQ("/" + endpoint, request.get().object().value());

  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response)
    << response.get().body;
}
// Tests that unauthorized requests for an agent endpoint are properly rejected.
TEST_P(SlaveEndpointTest, UnauthorizedRequest)
{
  const string endpoint = GetParam();

  StandaloneMasterDetector detector;

  MockAuthorizer mockAuthorizer;

  Try<Owned<cluster::Slave>> agent = StartSlave(&detector, &mockAuthorizer);
  ASSERT_SOME(agent);

  EXPECT_CALL(mockAuthorizer, authorized(_))
    .WillOnce(Return(false));

  Future<Response> response = http::get(
      agent.get()->pid,
      endpoint,
      None(),
      createBasicAuthHeaders(DEFAULT_CREDENTIAL));

  AWAIT_EXPECT_RESPONSE_STATUS_EQ(Forbidden().status, response)
    << response.get().body;
}
kern_return_t
do_LKDCDiscoverRealm (__unused mach_port_t port, 
					  hostnameIn_t hostname,
					  realmNameOut_t realm,
					  int *err,
					  audit_token_t token)
{
	LKDCLocator    *lkdc;
	int				error = 0;

	LKDCLogEnter ();

	realm[0] = '\0';

	if (!authorized(token)) {
		error = kLKDCHelperNotAuthorized;
		goto fin;
	}
	
	LKDCLog ("Looking up realm for %s", hostname);
	
	error = LKDCRealmForHostname (hostname, &lkdc);
	
	if (0 != error || NULL == lkdc->realmName) {
		goto fin;
	}
	
	strlcpy (realm, lkdc->realmName, sizeof (realmNameOut_t));

fin:
	update_idle_timer();

	*err = error;
	LKDCLogExit (error);

	return KERN_SUCCESS;
}
Example #20
0
void OAuthAuthorization::requestFinished()
{
	emit authorized(QNetworkReply::NoError == Reply->error());
	deleteLater();
}
Example #21
0
int main(int ac, char *av[])
{
	struct  sockaddr_in   saddr;   /* build our address here */
	struct	hostent		*hp;   /* this is part of our    */
	char	hostname[HOSTLEN];     /* address 	         */
	int	sock_id,sock_fd;       /* line id, file desc     */
	FILE	*sock_fp;              /* use socket as stream   */
	char    *ctime();              /* convert secs to string */
	time_t  thetime;               /* the time we report     */
	struct  sockaddr_in clnt_addr; /* who is calling us      */
	int     sin_len;               /* and the length         */

	char	**okcallers = NULL ;   /* used for screening     */

	if ( ac > 1 )
		okcallers = get_authorized(av[1]);
      /*
       * Step 1: ask kernel for a socket
       */

	sock_id = socket( PF_INET, SOCK_STREAM, 0 );    /* get a socket */
	if ( sock_id == -1 ) 
		oops( "socket" );

      /*
       * Step 2: bind address to socket.  Address is host,port
       */

	bzero( (void *)&saddr, sizeof(saddr) ); /* clear out struct     */

	gethostname( hostname, HOSTLEN );       /* where am I ?         */
	hp = gethostbyname( hostname );         /* get info about host  */
	                                        /* fill in host part    */
	bcopy( (void *)hp->h_addr, (void *)&saddr.sin_addr, hp->h_length);
	saddr.sin_port = htons(PORTNUM);        /* fill in socket port  */
	saddr.sin_family = AF_INET ;            /* fill in addr family  */

	if ( bind(sock_id, (struct sockaddr *)&saddr, sizeof(saddr)) != 0 )
	       oops( "bind" );

      /*
       * Step 3: allow incoming calls with Qsize=1 on socket
       */

	if ( listen(sock_id, 1) != 0 ) 
		oops( "listen" );

      /*
       * main loop: accept(), write(), close()
       */

	while ( 1 )
	{
		/* 
		 * remember to set the length variable 
		 * before calling accept
		 */
	       sin_len = sizeof(struct sockaddr);
	       sock_fd = accept(sock_id, 
			       	(struct sockaddr *)&clnt_addr, &sin_len);

	       if ( sock_fd == -1 )	       /* check for errors     */
		       oops( "accept" );

	       /*
		* if screening and not ok, close and take next call
		*/
	       if ( okcallers && !authorized(okcallers,clnt_addr.sin_addr))
	       {
		       close(sock_fd);
		       continue;
	       }

	       sock_fp = fdopen(sock_fd,"w");  /* we'll write to the   */
	       if ( sock_fp == NULL )          /* socket as a stream   */
		       oops( "fdopen" );       /* unless we can't      */

	       thetime = time(NULL);           /* get time             */
					       /* and convert to strng */
	       fprintf( sock_fp, "The time here is .." );
	       fprintf( sock_fp, "%s", ctime(&thetime) ); 
	       fclose( sock_fp );              /* release connection   */
	}
	return 0;
}
Example #22
0
void do_divorce ( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *	spouse1;
    CHAR_DATA *	spouse2;
    char	arg1 [ MAX_INPUT_LENGTH ];
    char	arg2 [ MAX_INPUT_LENGTH ];
    char	buf  [ MAX_STRING_LENGTH ];

    if ( !authorized( ch, "divorce" ) )
	return;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    if ( arg2[0] == '\0' )
    {
	send_to_char(AT_PURPLE, "Syntax:\n\r", ch );
	send_to_char(AT_WHITE, "divorce <person1> <person2>\n\r", ch );
	return;
    }

    if ( !(spouse1 = get_char_room( ch, arg1 ) )
      || !(spouse2 = get_char_room( ch, arg2 ) ) )
    {
	send_to_char(C_DEFAULT, "But they are not both present here!\n\r", ch );
	return;
    }

    if ( IS_NPC( spouse1 ) || IS_NPC( spouse2 ) )
    {
	send_to_char(C_DEFAULT, "Mobiles cannot marry.\n\r", ch );
	return;
    }

    if ( spouse1 == spouse2 )
    {
	send_to_char(C_DEFAULT, "You have to enter two DIFFERENT names!\n\r", ch );
	return;
    }


    if ( !spouse1->pcdata->spouse
      || !spouse2->pcdata->spouse )
    {
	sprintf( buf, "But %s isn't even married yet!\n\r",
	    !spouse1->pcdata->spouse ? spouse1->name
	    : spouse2->name );
	    send_to_char(C_DEFAULT, buf, ch );
	    return;
    }
    else if ( ( str_cmp( spouse1->name, spouse2->pcdata->spouse ) )
      || ( str_cmp( spouse2->name, spouse1->pcdata->spouse ) ) )
	send_to_char(C_DEFAULT, "But they're not married with each other!\n\r", ch );

	spouse1->pcdata->spouse = NULL;
	spouse2->pcdata->spouse = NULL;		/* Fix by Maniac */

    sprintf( buf, "%s and %s have just divorced each other\n\r", spouse1->name,
	spouse2->name );
    log_string( buf, CHANNEL_INFO, -1);

    return;
}
Example #23
0
/*
 * Code to create rings for married people.... Used in do_marry to give
 * the newly weds their initial rings, but can be used by imms also to
 * reimburse lost rings (for whatever reason)
 * Usage: newring <char>
 * The ring will be given to char automatically.
 * This is part of the marriage code by Canth ([email protected])
 * of Mythran
 */
void do_rings ( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA	*spouse1;
    CHAR_DATA	*spouse2;
    char	buf  [ MAX_STRING_LENGTH ];
    OBJ_DATA 	*ring;
    EXTRA_DESCR_DATA * ed;

    if ( !authorized( ch, "rings" ) )
	return;


    if (   !(spouse1 = get_char_world( ch, argument ) )
	|| !(spouse2 = get_char_world( ch, spouse1->pcdata->spouse ) ) )
    {
	send_to_char(C_DEFAULT, "They both need to be logged on to create the ring\n\r", ch );
	return;
    }

    /* Ok, they're both logged on... Let's see what sex spous1 is,
       and give them appropriate ring, and string it properly */

    switch( spouse1->sex )
    {
	case SEX_FEMALE:
	{
	    ring = create_object( get_obj_index( OBJ_VNUM_DIAMOND_RING ), 0 );
	    switch( spouse2->sex )
	    {
		case SEX_FEMALE:
		{
		    sprintf( buf, "This is the beautiful diamond ring given to you by your lovely\n\rwife %s at your wedding. It signifies your eternal love for eachother.", spouse2->name );
		    ring->description = str_dup( buf );
		    break;
		}
		case SEX_MALE:
		{
		    sprintf( buf, "This is the beautiful diamond ring given to you by your handsome\n\rhusband %s at your wedding. It signifies your eternal love for eachother.", spouse2->name );
		    ring->description = str_dup( buf );
		    break;
		}
		case SEX_NEUTRAL:
		default:
		{
		    sprintf( buf, "This is the beautiful diamond ring given to you by your\n\rspouse %s at your wedding. It signifies your eternal love for eachother.", spouse2->name );
		    ring->description = str_dup( buf );
		    break;
		}
	    }
		ed = new_extra_descr();

	    ed->keyword = str_dup( "inscription" );
	    sprintf( buf, "The inscription reads:\n\rTo my lovely wife, yours forever, %s", spouse2->name );
	    ed->description = str_dup( buf );
	    ed->deleted = FALSE;
	    ed->next = ring->extra_descr;
	    ring->extra_descr = ed;
	    break;
	}
	case SEX_MALE:
	case SEX_NEUTRAL:
	default:
	{
	    ring = create_object( get_obj_index( OBJ_VNUM_WEDDING_BAND ), 0 );
	    switch( spouse2->sex )
	    {	/* Description of the ring, depending on sex of spouse */
		case SEX_FEMALE:
		{
		    sprintf( buf, "This is the ring given to you by your beautifull wife %s\n\rat your wedding. It signifies your eternal love for eachother.", spouse2->name );
		    ring->description = str_dup( buf );
		    break;
		}
		case SEX_MALE:
		{
		    sprintf( buf, "This is the ring given to you by your handsome husband %s\n\rat your wedding. It signifies your eternal love for eachother.", spouse2->name );
		    ring->description = str_dup( buf );
		    break;
		}
		case SEX_NEUTRAL:
		default:
		{
		    sprintf( buf, "This is the ring given to you by your spouse %s at\n\ryour wedding. It signifies your eternal love for eachother.", spouse2->name );
		    ring->description = str_dup( buf );
		    break;
		}
	    }

	    /* Extra info for "look inscription" */

		ed =new_extra_descr();

	    ed->keyword = str_dup( "inscription" );
	    ed->deleted = FALSE;
	    ed->next = ring->extra_descr;
	    ring->extra_descr = ed;


	    switch( spouse1->sex )
	    {
		default:
		case SEX_MALE:
		{
		    sprintf( buf, "The inscription reads:\n\rTo my handsome prince... Forever yours, %s", spouse2->name );
		    ed->description = str_dup( buf );
		    break;
		}
		case SEX_NEUTRAL:
		{
		    sprintf( buf,"The inscription reads:\n\rForever love, %s", spouse2->name );
		    ed->description = str_dup( buf );
		    break;
		}
	    }
	}
    }

    obj_to_char ( ring, spouse1 );

    return;
}
Example #24
0
/*
 * Marriage code... Marries and divorces 2 ppl.
 * the chars have to be in the same room as the implementor using the command.
 * This is part of the marriage code by Canth ([email protected])
 * of Mythran
 */
void do_marry( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *	spouse1;
    CHAR_DATA *	spouse2;
    char	arg1 [ MAX_INPUT_LENGTH ];
    char	arg2 [ MAX_INPUT_LENGTH ];
    char	buf  [ MAX_STRING_LENGTH ];

    if ( !authorized( ch, "marry" ) )
	return;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    /* Make sure two arguments are given */
    if ( arg2[0] == '\0' )
    {
	send_to_char(AT_PURPLE, "Syntax:\n\r", ch );
	send_to_char(AT_WHITE, "marry <person1> <person2>\n\r", ch );
	return;
    }

    /* Make sure 2 characteres are given */
    if ( !(spouse1 = get_char_room( ch, arg1 ) )
      || !(spouse2 = get_char_room( ch, arg2 ) ) )
    {
	send_to_char(C_DEFAULT, "But they are not both present here!\n\r", ch );
	return;
    }

    /* Check for NPC's... They cannot marry. Maybe in a later version */
    if ( IS_NPC( spouse1 ) || IS_NPC( spouse2 ) )
    {
	send_to_char(C_DEFAULT, "Mobiles cannot marry.\n\r", ch );
	return;
    }

    /* Let's not marry or divorce one person to themsleves */
    if ( spouse1 == spouse2 )
    {
	send_to_char(C_DEFAULT, "You have to enter two DIFFERENT names!\n\r", ch );
	return;
    }


    /* Ok, a marriage :) */
    if ( spouse1->pcdata->spouse
      || spouse2->pcdata->spouse )
    {	
	sprintf( buf,
		"%s is already married to %s. No bigammy allowed here\n\r",
		!spouse1->pcdata->spouse
			? spouse2->name : spouse1->name,
		!spouse1->pcdata->spouse
			? spouse2->pcdata->spouse : spouse1->pcdata->spouse );
	send_to_char(C_DEFAULT, buf, ch );
	return;
    }

    spouse1->pcdata->spouse = str_dup( spouse2->name );
    spouse2->pcdata->spouse = str_dup( spouse1->name );

    /* The rings.... */
    do_rings( ch, spouse1->name );
    do_rings( ch, spouse2->name );

    sprintf( buf, "%s and %s have just married each other\n\r", spouse1->name,
	spouse2->name );
    log_string( buf, CHANNEL_INFO, -1);

    return;
    /* That's all folks! */
}
Example #25
0
LTWindow::LTWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::LTWindow), eventData(EventData::getInstance())
{    
    ui->setupUi(this);    

    currDriver = -1;

    streamReader = new DataStreamReader(this);
    prefs = new PreferencesDialog(this);
    settings = new QSettings(F1LTCore::iniFile(), QSettings::IniFormat, this);
    loginDialog = new LoginDialog(this);
    ltFilesManagerDialog = new LTFilesManagerDialog(this);
    trackRecordsDialog = new TrackRecordsDialog(this);
    saw = new SessionAnalysisWidget();
    stw = new SessionTimesWidget();
    driverTrackerWidget = new DriverTrackerWidget();
    aboutDialog = new AboutDialog(this);
    updatesCheckerDialog = new UpdatesCheckerDialog(this);

//    ui->trackStatusWidget->setupItems();

    connect(streamReader, SIGNAL(tryAuthorize()), this, SLOT(tryAuthorize()));
    connect(streamReader, SIGNAL(authorized(QString)), this, SLOT(authorized(QString)));
    connect(streamReader, SIGNAL(eventDataChanged(const DataUpdates&)), this, SLOT(eventDataChanged(const DataUpdates&)));
    connect(streamReader, SIGNAL(driverDataChanged(int, const DataUpdates&)), this, SLOT(driverDataChanged(int, const DataUpdates&)));
    connect(streamReader, SIGNAL(dataChanged(const DataUpdates&)), this, SLOT(dataChanged(const DataUpdates&)));
    connect(streamReader, SIGNAL(sessionStarted()), this, SLOT(sessionStarted()));
    connect(streamReader, SIGNAL(authorizationError()), this, SLOT(authorizationError()));
    connect(streamReader, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
    connect(streamReader, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError)));
    connect(streamReader, SIGNAL(noLiveSession(bool, QString)), this, SLOT(showNoSessionBoard(bool, QString)));

    connect(updatesCheckerDialog, SIGNAL(newVersionAvailable()), this, SLOT(onNewVersionAvailable()));

    sessionTimer = new SessionTimer(this);
    connect(sessionTimer, SIGNAL(updateWeather()), this, SLOT(updateWeather()));

    connect(&SeasonData::getInstance(), SIGNAL(seasonDataChanged()), &ImagesFactory::getInstance(), SLOT(reloadGraphics()));
    connect(&SeasonData::getInstance(), SIGNAL(seasonDataChanged()), &ColorsManager::getInstance(), SLOT(calculateDefaultDriverColors()));
    connect(&SeasonData::getInstance(), SIGNAL(seasonDataChanged()), saw, SLOT(setupColors()));


    connect(prefs, SIGNAL(driversColorsChanged()), saw, SLOT(setupColors()));

    eventRecorder = new EventRecorder(sessionTimer, this);
    eventPlayer = new EventPlayer(this);

    delayWidget = new DelayWidget(this);
    connect(delayWidget, SIGNAL(delayChanged(int, int)), streamReader, SLOT(setDelay(int, int)));
    connect(delayWidget, SIGNAL(delayChanged(int, int)), sessionTimer, SLOT(setDelay(int, int)));
    connect(sessionTimer, SIGNAL(synchronizingTimer(bool)), delayWidget, SLOT(synchronizingTimer(bool)));
    connect(sessionTimer, SIGNAL(synchronizingTimer(bool)), driverTrackerWidget, SLOT(pauseTimer(bool)));

    connect(ui->messageBoardWidget, SIGNAL(connectClicked()), this, SLOT(on_actionConnect_triggered()));
    connect(ui->messageBoardWidget, SIGNAL(playClicked()), this, SLOT(on_actionOpen_triggered()));
    connect(ui->messageBoardWidget, SIGNAL(loadClicked()), this, SLOT(on_actionLT_files_data_base_triggered()));

    loadSettings();
    ColorsManager::getInstance().calculateDefaultDriverColors();
    saw->setupColors();

    delayWidgetAction = ui->mainToolBar->addWidget(delayWidget);
    delayWidgetAction->setVisible(true);

    eventPlayerAction = ui->mainToolBar->addWidget(eventPlayer);
    eventPlayerAction->setVisible(false);
    recording = false;
    playing = false;

    connectionProgress = new QProgressDialog(this);

    connect(sessionTimer, SIGNAL(timeout()), this, SLOT(timeout()));
    connect(eventRecorder, SIGNAL(recordingStopped()), this, SLOT(autoStopRecording()));
    connect(eventPlayer, SIGNAL(playClicked(int)), this, SLOT(eventPlayerPlayClicked(int)));
    connect(eventPlayer, SIGNAL(pauseClicked()), this, SLOT(eventPlayerPauseClicked()));
    connect(eventPlayer, SIGNAL(rewindToStartClicked()), this, SLOT(eventPlayerRewindToStartClicked()));
    connect(eventPlayer, SIGNAL(forwardToEndClicked()), this, SLOT(eventPlayerForwardToEndClicked()));
    connect(eventPlayer, SIGNAL(rewindClicked()), this, SLOT(eventPlayerRewindClicked()));
    connect(eventPlayer, SIGNAL(stopClicked()), this, SLOT(eventPlayerStopClicked()));
    connect(eventPlayer, SIGNAL(nextPackets(QVector<Packet>)), streamReader, SLOT(parsePackets(QVector<Packet>)));

    connect(ui->ltWidget, SIGNAL(driverSelected(int)), ui->driverDataWidget, SLOT(printDriverData(int)));
    connect(ui->ltWidget, SIGNAL(driverDoubleClicked(int)), this, SLOT(ltWidgetDriverSelected(int)));


    ui->messageBoardWidget->setVisible(false);

    QStringList args = qApp->arguments();
    if (args.size() > 1)
    {
        if (eventPlayer->loadFromFile(args.at(1)) == false)
        {
            QMessageBox::critical(this, "Error opening file!", "Could not open specified file, or the file is corrupted.");
            connectToServer();
            return;
        }
        setWindowTitle("FILT - " + args.at(1));
        ui->actionRecord->setVisible(false);
        ui->actionStop_recording->setVisible(false);
        eventPlayerAction->setVisible(true);
        delayWidgetAction->setVisible(false);

        playing = true;

        eventPlayer->startPlaying();
    }
    else
    {
    	if (settings->value("ui/auto_connect").toBool())
    		connectToServer();
    	else
    	{
    		ui->messageBoardWidget->showStartupBoard();
    		showSessionBoard(true);
    	}
    }    

}
Example #26
0
papi_status_t
papiJobModify(papi_service_t handle, char *printer, int32_t job_id,
		papi_attribute_t **attributes, papi_job_t *job)
{
	papi_status_t status;
	job_t *j = NULL;
	service_t *svc = handle;
	char *file = NULL;
	char *dest;
	REQUEST *r = NULL;
	char lpfile[BUFSIZ];

	if ((svc == NULL) || (printer == NULL) || (job_id < 0) ||
	    (attributes == NULL))
		return (PAPI_BAD_ARGUMENT);

	if ((status = authorized(svc, job_id)) != PAPI_OK)
		return (status);

	if ((*job = j = calloc(1, sizeof (*j))) == NULL)
		return (PAPI_TEMPORARY_ERROR);

	dest = printer_name_from_uri_id(printer, job_id);
	status = lpsched_start_change(svc, dest, job_id, &file);
	if (status != PAPI_OK)
		return (status);

	if ((r = getrequest(file)) != NULL) {
		job_attributes_to_lpsched_request(handle, r,
				(papi_attribute_t **)attributes);
#ifdef LP_USE_PAPI_ATTR
		/*
		 * store the job attributes in the PAPI job attribute file
		 * that was created by the origonal job request. We need to
		 * modify the attributes in the file as per the new attributes
		 */
		snprintf(lpfile, sizeof (lpfile), "%s%d-%s",
			"/var/spool/lp/temp/", job_id, LP_PAPIATTRNAME);
		status = psm_modifyAttrsFile(attributes, lpfile);
		if (status != PAPI_OK) {
			detailed_error(svc,
				"unable to modify the attributes file: %s: %s",
				lpfile, strerror(errno));
			return (PAPI_DEVICE_ERROR);
		}
#endif

		if (putrequest(file, r) < 0) {
			detailed_error(svc,
				gettext("failed to write job: %s: %s"),
				file, strerror(errno));
			freerequest(r);
			return (PAPI_DEVICE_ERROR);
		}
	} else {
		detailed_error(svc, gettext("failed to read job: %s: %s"),
				file, strerror(errno));
		return (PAPI_DEVICE_ERROR);
	}

	status = lpsched_end_change(svc, dest, job_id);
	lpsched_request_to_job_attributes(r, j);
	freerequest(r);

	return (status);
}