Example #1
0
void
evaluer(void)
{
    int evaluations_restantes; 
    /* C'est fastidieux de devoir répondre oui à la question 'Continuer?'
     * après chaque x. Cette variable permet à l'utilisateur de spécifier
     * le nombre d'évaluations à faire pour éviter de répéter la question
     */
    double xtest;

    evaluations_restantes = 1;
    while(evaluations_restantes){
        evaluations_restantes --; //Soustraire la présente évaluation
        invite("Entrez la valeur de x:");
        scanf("%lf",&xtest);

        info("La valeur de la fonction en ");
        printf("%lf est:\t%lf",xtest,p_neville(xtest));

        if(!evaluations_restantes)
        {
            invite("Une autre évaluation?\n\t"
                    "(1 = oui, 0 = non, k = k évaluations consécutives):");
            scanf("%d",&evaluations_restantes);
        }
    }

    menu();
}
Example #2
0
char* SIPClient::inviteWithPassword(char const* url, char const* username,
				    char const* password) {
  delete[] (char*)fUserName; fUserName = strDup(username);
  fUserNameSize = strlen(fUserName);

  Authenticator authenticator(username, password);
  char* inviteResult = invite(url, &authenticator);
  if (inviteResult != NULL) {
    // We are already authorized
    return inviteResult;
  }

  // The "realm" and "nonce" fields should have been filled in:
  if (authenticator.realm() == NULL || authenticator.nonce() == NULL) {
    // We haven't been given enough information to try again, so fail:
    return NULL;
  }

  // Try again (but with the same CallId):
  inviteResult = invite1(&authenticator);
  if (inviteResult != NULL) {
    // The authenticator worked, so use it in future requests:
    fValidAuthenticator = authenticator;
  }

  return inviteResult;
}
Example #3
0
void
saisie_donnees(void)
{
    int i;

    for (i = 0; i < n; i++)
    {
        invite("x[%d] =\t", i + 1);
        scanf("%lf", x + i);
        vider_stdin();

        invite("y[%d] =\t", i + 1);
        scanf("%lf", y + i);
        vider_stdin();
    }
}
Example #4
0
/* MAIN --------------------------------------------------------------------------------*/
int main(int argc, char ** argv)
{
	struct argument * argList = NULL;
	int error;
	struct execNode * execList = NULL;
	printf("\nWelcome to Cthulhu sHEll.\nPh'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.\n\n");
	do {
		execList = NULL;
		argList = NULL;
		invite();
		error = ParseString(&argList);
		if (!error) {
			int zombie;
			execList = List2arg(argList);
			Execution(execList);
			while ((zombie = waitpid(-1, NULL, WNOHANG)) > 0)
				printf("chell: [%i] terminated\n", zombie);
		}
		if (error == 1)
			break;
		if (error == 2)
			printf("Mismatched quotes\n");
		FreeExec(execList);
		while (argList) {
			struct argument * tmpArg = argList;
			argList = argList->next;
			free(tmpArg);
		}
	} while (error != 1);
	printf("\n");
	return 0;
}
Example #5
0
void
do_invite()
{
    char *the_user;
    unsigned int user_id;

    cprintf("\1f\1r\nUser to invite to %s\1w>\1r: \1a", quickroom.name);
    nox = 1;
    the_user = get_name(2);

    if (strlen(the_user) == 0)
	return;

    if (mono_sql_u_check_user(the_user) == FALSE) {
	cprintf("\1f\1rNo such user.\1a\n");
	return;
    }
    if (invite(the_user, curr_rm) == -1) {
	cprintf("\1f\1rSomething went wrong inviting that user.\n\1a");
	return;
    }
    mono_cached_sql_u_name2id(the_user, &user_id);
    mono_sql_uf_add_invited(user_id, curr_rm);

    log_sysop_action("invited %s into %s>.", the_user, quickroom.name);

    return;
}
Example #6
0
/**
 * Event handler pro kliknutí na tlačítko pro pozvání do hry
 * @param event
 */
void LobbyWindow::clickInvite(wxCommandEvent &event)
{
    if (selectedPlayer != _(""))
    {
        invite(selectedPlayer);
    }
}
Example #7
0
void set_y0(void)
{
    invite("y0 = y(x0) =");
    scanf("%lf",&y_zero);
    vider_stdin();

    menu();
}
Example #8
0
void getf(void)
{
    info("["XSTR(EXP_MAX_SIZE)" caractères max, appuyez sur ENTRER pour utiliser l'expression précédente]");
    invite("f(x,y) =");
    scanf("%"XSTR(EXP_MAX_SIZE)"[^\n]",expression);
    (void) getchar();
    menu();
}
Example #9
0
void set_f(void)
{
    invite("f(x,y) = ("XSTR(EXP_SIZE)" caractères max):");
    scanf(" %"XSTR(EXP_SIZE)"[^\n]",exp_f);
    (void) getchar();

    if(!debut)
        menu();
}
Example #10
0
void set_abn(void)
{
    invite("a =");
    scanf("%lf",&a);
    vider_stdin();

    invite("b =");
    scanf("%lf",&b);
    vider_stdin();

    invite("n =");
    scanf("%d",&n);
    vider_stdin();

    h = (b - a)/((double) (n - 1));
    if(!debut)
        menu();
}
void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData)
{
    uint64 guid = _player->GetGUID();

    std::string title;
    std::string description;
    uint8 type;
    uint8 repeatable;
    uint32 maxInvites;
    int32 dungeonId;
    uint32 eventPackedTime;
    uint32 unkPackedTime;
    uint32 flags;

    recvData >> title >> description >> type >> repeatable >> maxInvites >> dungeonId;
    recvData.ReadPackedTime(eventPackedTime);
    recvData.ReadPackedTime(unkPackedTime);
    recvData >> flags;

    CalendarEvent calendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId,
        time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description);

    if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement())
        if (Player* creator = ObjectAccessor::FindPlayer(guid))
            calendarEvent.SetGuildId(creator->GetGuildId());

    if (calendarEvent.IsGuildAnnouncement())
    {
        // 946684800 is 01/01/2000 00:00:00 - default response time
        CalendarInvite invite(0, calendarEvent.GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, "");
        // WARNING: By passing pointer to a local variable, the underlying method(s) must NOT perform any kind
        // of storage of the pointer as it will lead to memory corruption
        sCalendarMgr->AddInvite(&calendarEvent, &invite);
    }
    else
    {
        uint32 inviteCount;
        recvData >> inviteCount;

        for (uint32 i = 0; i < inviteCount; ++i)
        {
            uint64 invitee = 0;
            uint8 status = 0;
            uint8 rank = 0;
            recvData.readPackGUID(invitee);
            recvData >> status >> rank;

            // 946684800 is 01/01/2000 00:00:00 - default response time
            CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent.GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), "");
            sCalendarMgr->AddInvite(&calendarEvent, invite);
        }
    }

    sCalendarMgr->AddEvent(new CalendarEvent(calendarEvent, calendarEvent.GetEventId()), CALENDAR_SENDTYPE_ADD);
}
void ExpeditionRequestWidget::initialize() {
	mVMainLayout = new QVBoxLayout();
	mUnaskedLayout = new QVBoxLayout();
	mAskedLayout = new QVBoxLayout();
	mSplitter = new QSplitter();

	mUnaskedView.setModel(&mUnaskedModel);
	mUnaskedView.setSelectionMode(QAbstractItemView::ExtendedSelection);
	mUnaskedView.setSpacing(2);
	mAskedView.setModel(&mAskedModel);	
	mAskedView.setSelectionMode(QAbstractItemView::ExtendedSelection);
	mAskedView.setSpacing(2);

	mUnaskedToAskedButton.setText("-->");
	mAskedToUnaskedButton.setText("<--");
	mInviteButton.setText("Invite / Uninvite");
	mUnaskedLayout->addWidget(new QLabel("Invitable Users"));
	mUnaskedLayout->addWidget(&mUnaskedView);
	mUnaskedLayout->addWidget(&mUnaskedToAskedButton);
	mAskedLayout->addWidget(new QLabel("Invited Users"));
	mAskedLayout->addWidget(&mAskedView);	
	mAskedLayout->addWidget(&mAskedToUnaskedButton);
	mUnaskedWidget.setLayout(mUnaskedLayout);
	mAskedWidget.setLayout(mAskedLayout);
	mSplitter->addWidget(&mUnaskedWidget);
	mSplitter->addWidget(&mAskedWidget);

	QLabel* l = new QLabel("Please Move the Users You'd Like to Invite into the Right Column and Users You'd Like to Uninvite (kick) Into the Left");
	l->setWordWrap(true);
	l->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
	mVMainLayout->addWidget(l);
	mColorLabel.setText("Choose a Color to Identify Your Party:");
	mColorLabel.setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
	mVMainLayout->addWidget(&mColorLabel);
	mColorButton.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
	mColorButton.setRandomColor();
	mVMainLayout->addWidget(&mColorButton);
	mVMainLayout->addWidget(mSplitter);
	mVMainLayout->addWidget(&mInviteButton);

	setWindowTitle("Browsing Party Manager"); 
	setLayout(mVMainLayout);

	connect(&mUnaskedToAskedButton, SIGNAL(clicked()), this, SLOT(moveUnaskedToAsked()));
	connect(&mAskedToUnaskedButton, SIGNAL(clicked()), this, SLOT(moveAskedToUnasked()));
	connect(&mInviteButton, SIGNAL(clicked()), this, SLOT(invite()));

	connect(this, SIGNAL(controller_serverInviteToExpedition(const QColor&, QList<UserData*>)), Controller::self(), SIGNAL(serverInviteToExpedition(const QColor&, QList<UserData*>)));
	connect(this, SIGNAL(controller_serverUninviteFromExpedition(QList<UserData*>)), Controller::self(), SIGNAL(serverUninviteFromExpedition(QList<UserData*>)));

	connect(&mColorButton, SIGNAL(clicked()), this, SLOT(choosePartyColor()));

	mUnaskedModel.setRelationshipList(&mUnaskedList);
	mAskedModel.setRelationshipList(&mAskedList);	
}
Example #13
0
/**
  * Invites a user. The Format
  */
void ChatWidget::invite(QSharedPointer<const User> user, const QObject *id, bool success,
                        const QString &msg)
{
    QLOG_TRACE() << __PRETTY_FUNCTION__;
    if (id != this)
        return;
    if (success) {
        invite(user);
    } else {
        QMessageBox::warning(this, "Invite Failed", msg);
    }
}
Example #14
0
void evalf(void)
{
    double x,y;

    if(*expression == '\0') // aucune expression n'as été entrée
    {
        erreur("Désolé, f(x,y) n\'as pas été défini. Commencez par là ...");
    } else {
        info("Evaluation de f(x,y) en un point (x,y)");

        invite("x =");
        scanf("%lf", &x);
        vider_stdin();

        invite("y =");
        scanf("%lf", &y);
        vider_stdin();

        info("La valeur de la fonction en (%lf,%lf) est\t%lf",x,y,eval(expression,&x,&y));
    }

    menu();
}
Example #15
0
void
ouvrir_fichier(void)
{
    int choix,nb_champs; // nb_champs est le nombre de champs convertis par fscanf
    double x; // utilisé pour vérifier si les données sont au format attendu

    donnees = open_r(quel_nom(),0);

    if(!donnees)
    {
        if(!OF_abandon) // l'utilisateur n'as pas abandonné, c'est donc une erreur système
        {
            erreur("Une erreur système est survenue lors de l\'ouverture du ficher");
            info("Désolé pour le désagrément");
            info("Description système");
            perror("");
        }

        menu();
        return; // plus rien à faire ici
    }

    // A ce stade, le fichier est correctement ouvert
    // Basic sanity test, profitons-en pour calculer le nombre de points
    n = 0;
    nb_champs = 2;
    while(!feof(donnees) && nb_champs == 2)
    {
        nb_champs = fscanf(donnees,"%lf\t%lf\n", &x, &x);
        n ++;
    }

    if(!feof(donnees)) // on n'est toujours pas à la fin du fichier, il est donc mal formatté
    {
        info("Le fichier ne contient pas des données au format attendu");
        invite("Réessayer? (0 = non, 1 = oui):");
        scanf("%d",&choix);
        vider_stdin();

        if(choix == 0)
            menu();
        else
            ouvrir_fichier();

        return; // plus rien a faire ici, sortir
    }

    // Tout est normal, on a terminé    
    rewind(donnees); //Comme sur le magnétophone! ce sacré Ritchie!
}
Example #16
0
void du_fichier(void)
{
    int i,choix;

    info("Lecture des valeurs x[i] et y[i] à partir d'un fichier:");
    info("Le fichier doit contenir un point par ligne comme suit:\n");
    info("\tx[i]\ty[i]\n\t\tx[i+1]\ty[i+1]\n\t\t...");

    ouvrir_fichier();

    x = MALLOC(double,n);
    y = MALLOC(double,n);

    if((x == NULL) || (y == NULL))
    {
        erreur("Impossible d\'allouer la mémoire pour x et y (dans du_fichier())");
        perror("Description système de l\'erreur");
        menu();
        return;
    }

    for(i = 0; i < n; i ++)
    {
        fscanf(donnees,"%lf\t%lf\n",x+i,y+i);
    }
    fclose(donnees);

    if(verifier() == 0)
    {
        erreur("Les valeurs des xi ne sont pas deux a deux distinctes.");
        info("Vous pouvez :\n\t1 - Recommencer\n\t2 - Abandonner");
        invite("Votre choix :");
        scanf("%d",&choix);
        vider_stdin();

        if(choix == 1)
        {
            du_fichier();
            return; //plus rien à faire ici
        } else { // il abandonne
            menu();
            return;
        }
    }

    menu();
}
void WorldSession::HandleCalendarAddEvent(WorldPackets::Calendar::CalendarAddEvent& calendarAddEvent)
{
    ObjectGuid guid = _player->GetGUID();

    // prevent events in the past
    // To Do: properly handle timezones and remove the "- time_t(86400L)" hack
    if (calendarAddEvent.EventInfo.Time < (time(NULL) - time_t(86400L)))
        return;

    CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, UI64LIT(0), CalendarEventType(calendarAddEvent.EventInfo.EventType), calendarAddEvent.EventInfo.TextureID,
        calendarAddEvent.EventInfo.Time, calendarAddEvent.EventInfo.Flags, calendarAddEvent.EventInfo.Title, calendarAddEvent.EventInfo.Description, time_t(0));

    if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement())
        if (Player* creator = ObjectAccessor::FindPlayer(guid))
            calendarEvent->SetGuildId(creator->GetGuildId());

    if (calendarEvent->IsGuildAnnouncement())
    {
        CalendarInvite invite(0, calendarEvent->GetEventId(), ObjectGuid::Empty, guid, CALENDAR_DEFAULT_RESPONSE_TIME, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, "");
        // WARNING: By passing pointer to a local variable, the underlying method(s) must NOT perform any kind
        // of storage of the pointer as it will lead to memory corruption
        sCalendarMgr->AddInvite(calendarEvent, &invite);
    }
    else
    {
        SQLTransaction trans;
        if (calendarAddEvent.EventInfo.Invites.size() > 1)
            trans = CharacterDatabase.BeginTransaction();

        for (uint32 i = 0; i < calendarAddEvent.EventInfo.Invites.size(); ++i)
        {
            CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), calendarAddEvent.EventInfo.Invites[i].Guid,
                guid, CALENDAR_DEFAULT_RESPONSE_TIME, CalendarInviteStatus(calendarAddEvent.EventInfo.Invites[i].Status),
                CalendarModerationRank(calendarAddEvent.EventInfo.Invites[i].Moderator), "");
            sCalendarMgr->AddInvite(calendarEvent, invite, trans);
        }

        if (calendarAddEvent.EventInfo.Invites.size() > 1)
            CharacterDatabase.CommitTransaction(trans);
    }

    sCalendarMgr->AddEvent(calendarEvent, CALENDAR_SENDTYPE_ADD);
}
Example #18
0
void
edit_room_field(room_t * QRedit, unsigned int forum_id, int fieldnum)
{
    int loop, i, j = 0;
    char *quad_name;

    switch (fieldnum) {

	case '1':
	    cprintf("%s%s%s%s",
		  "\1rPlease keep length of name to under 36 characters.\n",
		    "\1w                        ",
		    "|------------------------------------|\n",
		    "\1rEnter new quadrant name\1w: \1c");
	    quad_name = get_name(3);
	    if (strlen(quad_name) < 1) {
		cprintf("\1gOk, name not changed.\n");
		break;
	    }
	    if (get_room_number(quad_name) != -1) {
		cprintf("\1rThat name is already taken, sorry.\n");
	    } else {
		log_sysop_action("changed %ss name into %s.",
				 QRedit->name, quad_name);
		strcpy(QRedit->name, quad_name);
		mono_sql_f_rename_forum(forum_id, quad_name);
		/* if we rename a guessname, up the generation no */
	        if ( QRedit->flags & QR_GUESSNAME ) 
		    QRedit->generation++;
		need_rewrite = TRUE;
	    }

	    break;

/*-------------------------------------------------------------------*/

	case '3':		/* room type */

	    cprintf("\1g%s Type: \1w<\1r1\1w> \1gPublic \1w<\1r2\1w> \1rPrivate \1w: \1c", config.forum);
	    loop = get_single("12");

	    if (loop == '1') {
		cprintf("\1g%s set to PUBLIC.\n\n", config.forum);
		QRedit->flags &= ~QR_PRIVATE;
	    } else if (loop == '2') {
		cprintf("\1r%s set to INVITE ONLY.\n\n", config.forum);
		QRedit->flags |= QR_PRIVATE;
		cprintf("Kick out all users? ");
		if (yesno() == YES) {
		    QRedit->generation++;
		    if (QRedit->generation == 100)
			QRedit->generation = 10;
		    if (invite(who_am_i(NULL), curr_rm) == -1)
			cprintf("Error inviting yourself.\n");
		}
	    }
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '4':
	    cprintf("\1gPostType: \1w<\1y1\1w> \1gNormal \1w<\1y2\1w>\1pAnon-only \1w<\1y3\1w>\1pAnon-option \1w: \1c");

	    loop = get_single("123");

	    if (loop == '1') {	/* normal room, remove flags */
		QRedit->flags &= ~QR_ANONONLY;
		QRedit->flags &= ~QR_ANON2;
	    }
	    if (loop == '2') {	/* anononly room, set & unset proper flags */
		QRedit->flags |= QR_ANONONLY;
		QRedit->flags &= ~QR_ANON2;
	    }
	    if (loop == '3') {	/* anonopt room */
		QRedit->flags |= QR_ANON2;
		QRedit->flags &= ~QR_ANONONLY;
	    }
	    if (QRedit->flags & (QR_ANONONLY | QR_ANON2)) {
		cprintf("\1gShould the users be able to use Aliasnames? (y/n) ");
		if (yesno() == YES)
		    QRedit->flags |= QR_ALIASNAME;
		else
		    QRedit->flags &= ~QR_ALIASNAME;
	    } else
		QRedit->flags &= ~QR_ALIASNAME;

	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '5':
	    QRedit->flags ^= QR_SUBJECTLINE;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '6':
	    QRedit->flags ^= QR_DESCRIBED;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '7':
	    QRedit->flags ^= QR_READONLY;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '8':
	    QRedit->flags ^= QR_NOZAP;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '9':
	    QRedit->flags ^= QR_INUSE;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '0':
	    QRedit->flags ^= QR_GUESSNAME;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case 'a':
	case 'A':
	    cprintf("\1rEnter the new maximum number of messages\1w(\1r%d\1w): \1c",
		    QRedit->maxmsg);
	    j = qc_get_pos_int('\0', 4);
	    if (j < 10) {
		cprintf("\1rDon't be daft! 10 messages is the minimum.\n");
		break;
	    } else if (j > 1000) {
		cprintf("\1rDon't be daft! 1000 messages is the maximum.\n");
		break;
	    } else {
		QRedit->maxmsg = j;
		need_rewrite = TRUE;
		break;
	    }

/*--------------------------------------------------------------------*/
	case 'b':
	case 'B':
	    cprintf("\1rEnter the new highest %s\1w: \1c", config.message);
	    j = qc_get_pos_int('\0', 7);
	    cprintf("\1f\1gAre you \1rSURE\1g you want to set the highest for `\1y%s\1g` to \1w%ld\1g? \1c", QRedit->name, j);
	    if (yesno() == YES) {
		QRedit->highest = j;
		cprintf("\1gIf you say so... done.\n");
		need_rewrite = TRUE;
	    }
	    break;
/*--------------------------------------------------------------------*/
	case 'c':
	case 'C':
	    cprintf("\1rEnter the new lowest %s\1w: \1c", config.message);
	    j = qc_get_pos_int('\0', 7);
	    cprintf("\1f\1gAre you \1rSURE\1g you want to set the lowest for `\1y%s\1g` to \1w%ld\1g? \1c", QRedit->name, j);
	    if (yesno() == YES) {
		QRedit->lowest = j;
		cprintf("\1gIf you say so... done.\n");
		need_rewrite = TRUE;
	    }
	    break;
/*--------------------------------------------------------------------*/
	case 'd':
	case 'D':

	    for (i = 0; i < CATEGORIES; i++)
		cprintf("\1w<\1r%2d\1w>\1g %s\n", i, fish[i]);

	    cprintf("\1gEnter the new category number\1w: \1c");

	    if ((i = qc_get_pos_int('\0', 2)) < 0)
		break;
	    else {
		if (i >= CATEGORIES) {
		    cprintf("\n\1r+++ OUT OF CHEESE ERROR - REDO FROM START +++\n\n");
		    break;
		} else {
		    strcpy(QRedit->category, fish[i]);
		    need_rewrite = TRUE;
		    break;
		}
		cprintf("\1r\1nUm, what?\n\n");
	    }
	    break;
/*--------------------------------------------------------------------*/

	default:
	    break;

    }				/* end switch */
}
Example #19
0
void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData)
{
    TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_INVITE");

    ObjectGuid playerGuid = _player->GetGUID();

    uint64 eventId;
    uint64 inviteId;
    std::string name;
    bool isPreInvite;
    bool isGuildEvent;

    ObjectGuid inviteeGuid;
    uint32 inviteeTeam = 0;
    uint32 inviteeGuildId = 0;

    recvData >> eventId >> inviteId >> name >> isPreInvite >> isGuildEvent;

    if (Player* player = ObjectAccessor::FindConnectedPlayerByName(name))
    {
        // Invitee is online
        inviteeGuid = player->GetGUID();
        inviteeTeam = player->GetTeam();
        inviteeGuildId = player->GetGuildId();
    }
    else
    {
        // Invitee offline, get data from database
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME);
        stmt->setString(0, name);
        if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
        {
            Field* fields = result->Fetch();
            inviteeGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
            inviteeTeam = Player::TeamForRace(fields[1].GetUInt8());
            inviteeGuildId = Player::GetGuildIdFromDB(inviteeGuid);
        }
    }

    if (!inviteeGuid)
    {
        sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_PLAYER_NOT_FOUND);
        return;
    }

    if (_player->GetTeam() != inviteeTeam && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR))
    {
        sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NOT_ALLIED);
        return;
    }

    if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = %u AND friend = %u", inviteeGuid.GetCounter(), playerGuid.GetCounter()))
    {
        Field* fields = result->Fetch();
        if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED)
        {
            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, name.c_str());
            return;
        }
    }

    if (!isPreInvite)
    {
        if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId))
        {
            if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == inviteeGuildId)
            {
                // we can't invite guild members to guild events
                sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES);
                return;
            }

            // 946684800 is 01/01/2000 00:00:00 - default response time
            CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, inviteeGuid, playerGuid, 946684800, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");
            sCalendarMgr->AddInvite(calendarEvent, invite);
        }
        else
            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_EVENT_INVALID);
    }
    else
    {
        if (isGuildEvent && inviteeGuildId == _player->GetGuildId())
        {
            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES);
            return;
        }

        // 946684800 is 01/01/2000 00:00:00 - default response time
        CalendarInvite invite(inviteId, 0, inviteeGuid, playerGuid, 946684800, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");
        sCalendarMgr->SendCalendarEventInvite(invite);
    }
}
Example #20
0
void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData)
{
    ObjectGuid guid = _player->GetGUID();

    std::string title;
    std::string description;
    uint8 type;
    uint8 repeatable;
    uint32 maxInvites;
    int32 dungeonId;
    uint32 eventPackedTime;
    uint32 unkPackedTime;
    uint32 flags;

    recvData >> title >> description >> type >> repeatable >> maxInvites >> dungeonId;
    recvData.ReadPackedTime(eventPackedTime);
    recvData.ReadPackedTime(unkPackedTime);
    recvData >> flags;

    // prevent events in the past
    // To Do: properly handle timezones and remove the "- time_t(86400L)" hack
    if (time_t(eventPackedTime) < (time(NULL) - time_t(86400L)))
    {
        recvData.rfinish();
        return;
    }

    CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId,
        time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description);

    if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement())
        if (Player* creator = ObjectAccessor::FindPlayer(guid))
            calendarEvent->SetGuildId(creator->GetGuildId());

    if (calendarEvent->IsGuildAnnouncement())
    {
        // 946684800 is 01/01/2000 00:00:00 - default response time
        CalendarInvite invite(0, calendarEvent->GetEventId(), ObjectGuid::Empty, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, "");
        // WARNING: By passing pointer to a local variable, the underlying method(s) must NOT perform any kind
        // of storage of the pointer as it will lead to memory corruption
        sCalendarMgr->AddInvite(calendarEvent, &invite);
    }
    else
    {
        // client limits the amount of players to be invited to 100
        const uint32 MaxPlayerInvites = 100;

        uint32 inviteCount;
        ObjectGuid invitee[MaxPlayerInvites];
        uint8 status[MaxPlayerInvites];
        uint8 rank[MaxPlayerInvites];

        memset(status, 0, sizeof(status));
        memset(rank, 0, sizeof(rank));

        try
        {
            recvData >> inviteCount;

            for (uint32 i = 0; i < inviteCount && i < MaxPlayerInvites; ++i)
            {
                recvData >> invitee[i].ReadAsPacked();
                recvData >> status[i] >> rank[i];
            }
        }
        catch (ByteBufferException const&)
        {
            delete calendarEvent;
            calendarEvent = NULL;
            throw;
        }

        SQLTransaction trans;
        if (inviteCount > 1)
            trans = CharacterDatabase.BeginTransaction();

        for (uint32 i = 0; i < inviteCount && i < MaxPlayerInvites; ++i)
        {
            // 946684800 is 01/01/2000 00:00:00 - default response time
            CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee[i], guid, 946684800, CalendarInviteStatus(status[i]), CalendarModerationRank(rank[i]), "");
            sCalendarMgr->AddInvite(calendarEvent, invite, trans);
        }

        if (inviteCount > 1)
            CharacterDatabase.CommitTransaction(trans);
    }

    sCalendarMgr->AddEvent(calendarEvent, CALENDAR_SENDTYPE_ADD);
}
Example #21
0
/**********************************************************************
* aide menu
* Access to this menu is restricted to those with aide status.
* Wizards can do everything
* System Aides can do all but aideify
* Room Aides can only get here if it's their room and they can
* NOT do <A>ideify <C>reateroom <Z>ap room.
**********************************************************************/
void
aide_menu(void)
{
register int chr = '?';

  /* Can't get here unless you're at least a room aide for this room */

  while (chr != 'M' && chr != ' ' && chr != '\n')
  {
    switch (chr)
    {
      case 'C':
	printf("Create new forum\n");
	createroom();
	loadroom();
	break;

      case 'D':
	printf("Edit forum description\n\n");
	editdesc();
	break;

      case 'E':
	printf("Edit forum\n");
	editroom();
	break;

      case 'H':
	printf("Help!\n");
	if (ouruser->f_admin)
	  help("aidemenu", YES);
	else
	  help("fmmenu", YES);
	break;

      case 'I':
	printf("Invite user\n");
	invite();
	break;

      case 'K':
	printf("Kick out user\n");
	kickout();
	break;

      case 'L':
	if (ouruser->f_prog)
	{
	  printf("Logout all users\n");
	  logout_all();
	  break;
	}
	/* FALL THRU */

      case 'l':
        printf("Logout user\n");
        logout();
        break;

      case 'O':
	show_online(1);
	break;

      case 'W':
	whoknows();
	break;

      case 'X':
	if (ouruser->f_prog)
	  xbroadcast();
	else
	  chr = 0;
	break;

      case 'Z':
	printf("Zap (delete) forum\n");
	deleteroom();
	loadroom();
	break;

      case '?':
      case '/':
	if (ouruser->f_admin)
	  help("aidecmd", NO);
	else
	  help("fmcmd", NO);
	break;

      default:
	break;
    }

    if (chr)
      colorize("\n@Y[%s]@M Forum command ->@G ", msg->room[curr].name);
    if (ouruser->f_admin)
      chr = get_single_quiet("CDEHIKlLMOWXZ \n/?");
    else
      chr = get_single_quiet("DEHIKMW \n/?");

  }				/* end of while loop */
  printf("Forum level\n");
}
Example #22
0
/*
 *Main thread for each client.  Receives all messages
 *and passes the data off to the correct function.  Receives
 *a pointer to the file descriptor for the socket the thread
 *should listen on
 */
void *client_receive(void *ptr) {
   int client = *(int *) ptr;
   int received;
   int logged_in = 0;
   packet in_pkt, *client_message_ptr = &in_pkt;

   while (1) {
      received = recv(client, &in_pkt, sizeof(packet), 0);
      if (received) {
         debugPacket(client_message_ptr);

         // Responses to not logged in clients
         if (!logged_in) {
            if(in_pkt.options == REGISTER) {
               logged_in = register_user(&in_pkt, client);
            }
            else if(in_pkt.options == LOGIN) {
               logged_in = login(&in_pkt, client);
            }
            else if(in_pkt.options == EXIT) {
               close(client);
               return NULL;
            }
            else {
               sendError("Not logged in.", client);
            }
         }

         // Responses to logged in clients
         else if (logged_in) {
            // Handle option messages for logged in client
            if (in_pkt.options < 1000) {
               if(in_pkt.options == REGISTER) { 
                  sendError("You may not register while logged in.", client);
               }
               else if(in_pkt.options == SETPASS) {
                  set_pass(&in_pkt, client);
               }
               else if(in_pkt.options == SETNAME) {
                  set_name(&in_pkt, client);
               }
               else if(in_pkt.options == LOGIN) {
                  sendError("Already logged in.", client);
               }
               else if(in_pkt.options == EXIT) {
                  exit_client(&in_pkt, client);
                  return NULL;
               }
               else if(in_pkt.options == INVITE) {
                  invite(&in_pkt, client);
               }
               else if(in_pkt.options == JOIN) {
                  join(&in_pkt, client);
               }
               else if(in_pkt.options == LEAVE) {
                  leave(&in_pkt, client);
               }
               else if(in_pkt.options == GETALLUSERS) {
                  get_active_users(client);
               }
               else if(in_pkt.options == GETUSERS) {
                  get_room_users(&in_pkt, client);
               }
               else if(in_pkt.options == GETUSER) {
                  user_lookup(&in_pkt, client);
               }
               else if(in_pkt.options == GETROOMS) {
                  get_room_list(client);
               }
               else if(in_pkt.options == GETMOTD) {
                  sendMOTD(client);
               }
               else if(in_pkt.options == 0) {
                  printf("%s --- Error:%s Abrupt disconnect on logged in client.\n", RED, NORMAL);
                  exit_client(&in_pkt, client);
                  return NULL;
               }
               else {
                  printf("%s --- Error:%s Unknown message received from client.\n", RED, NORMAL);
	       }
            }
            // Handle conversation message for logged in client
            else {
               // Will be treated as a message packet, safe to santize entire buffer
               sanitizeInput((void *)&in_pkt.buf, 0);
               send_message(&in_pkt, client);
            }
         }

         memset(&in_pkt, 0, sizeof(packet));
      }
   }
   return NULL;
}
Example #23
0
/*
 * numbered_command: does (hopefully) the right thing with the numbered
 * responses from the server.  I wasn't real careful to be sure I got them
 * all, but the default case should handle any I missed (sorry) 
 */
void
numbered_command(u_char *from, int comm, u_char **ArgList)
{
	u_char	*user;
	u_char	none_of_these = 0;
	u_char	blah[BIG_BUFFER_SIZE];
	int	flag,
		lastlog_level;
	const	int	from_server = parsing_server();
#if 0
	int	user_cnt,
		inv_cnt,
		server_cnt;
#endif /* 0 */

	if (!from || !*from)
		return;
	if (!*ArgList[0])
		user = NULL;
	else
		user = ArgList[0];
	if (!ArgList[1])
		return;
	lastlog_level = set_lastlog_msg_level(LOG_CRAP);
	save_message_from();
	message_from(NULL, LOG_CRAP);
	ArgList++;
	current_numeric_local = -comm;	/* must be negative of numeric! */
	switch (comm)
	{
	case 001:	/* #define RPL_WELCOME          001 */
		PasteArgs(ArgList, 0);
		if (my_strcmp(user, server_get_nickname(from_server)) != 0)
		{
			yell("=== Setting this servers nickname to \"%s\" from \"%s\"", user, server_get_nickname(from_server));
			server_set_nickname(from_server, user);
		}
		if (do_hook(current_numeric(), "%s %s", from, *ArgList)) 
			display_msg(from, ArgList);
		clean_whois_queue();
		break;
	case 002:	/* #define RPL_YOURHOST         002 */
		PasteArgs(ArgList, 0);
		snprintf(CP(blah), sizeof blah, "*** %s", ArgList[0]);
		got_initial_version(blah);
		if (do_hook(current_numeric(), "%s %s", from, *ArgList))
			display_msg(from, ArgList);
		break;

/* should do something with this some day, 2.8 had channel/user mode switches */
	case 004:	/* #define RPL_MYINFO           004 */
		PasteArgs(ArgList, 0);
		if (do_hook(current_numeric(), "%s %s", from, *ArgList))
			display_msg(from, ArgList);
		break;

/*
 * this part of ircii has been broken for most of ircd 2.7, so someday I'll
 * make it work for ircd 2.8 ...  phone..
 */
#if 0
	case 251:		/* #define RPL_LUSERCLIENT      251 */
		display_msg(from, ArgList);
		if (is_server_connected(from_server))
			break;
		if (from_server == get_primary_server() && ((sscanf(ArgList[1],
		    "There are %d users and %d invisible on %d servers",
		    &user_cnt, &inv_cnt, &server_cnt) == 3)||(sscanf(ArgList[1],
		    "There are %d users and %d invisible on %d servers",
		    &user_cnt, &inv_cnt, &server_cnt) == 3)))
		{
			user_cnt =+ inv_cnt;
			if ((server_cnt < get_int_var(MINIMUM_SERVERS_VAR)) ||
			    (user_cnt < get_int_var(MINIMUM_USERS_VAR)))
			{
				say("Trying better populated server...");
				get_connected(from_server + 1);
			}
		}
		break;
#endif /* 0 */
	case 301:		/* #define RPL_AWAY             301 */
		user_is_away(from, ArgList);
		break;

	case 302:		/* #define RPL_USERHOST         302 */
		userhost_returned(from, ArgList);
		break;

	case 303:		/* #define RPL_ISON             303 */
		ison_returned(from, ArgList);
		break;

	case 311:		/* #define RPL_WHOISUSER        311 */
		whois_name(from, ArgList);
		break;

	case 312:		/* #define RPL_WHOISSERVER      312 */
		whois_server(from, ArgList);
		break;

	case 313:		/* #define RPL_WHOISOPERATOR    313 */
		whois_oper(from, ArgList);
		break;

	case 314:		/* #define RPL_WHOWASUSER       314 */
		whowas_name(from, ArgList);
		break;

	case 316:		/* #define RPL_WHOISCHANOP      316 */
		whois_chop(from, ArgList);
		break;

	case 317:		/* #define RPL_WHOISIDLE        317 */
		whois_lastcom(from, ArgList);
		break;

	case 318:		/* #define RPL_ENDOFWHOIS       318 */
		end_of_whois(from, ArgList);
		break;

	case 319:		/* #define RPL_WHOISCHANNELS    319 */
		whois_channels(from, ArgList);
		break;

	case 321:		/* #define RPL_LISTSTART        321 */
		ArgList[0] = UP("Channel\0Users\0Topic");
		ArgList[1] = ArgList[0] + 8;
		ArgList[2] = ArgList[1] + 6;
		ArgList[3] = NULL;
		funny_list(from, ArgList);
		break;

	case 322:		/* #define RPL_LIST             322 */
		funny_list(from, ArgList);
		break;

	case 324:		/* #define RPL_CHANNELMODEIS    324 */
		funny_mode(from, ArgList);
		break;

	case 341:		/* #define RPL_INVITING         341 */
		invite(from, ArgList);
		break;

	case 352:		/* #define RPL_WHOREPLY         352 */
		whoreply(NULL, ArgList);
		break;

	case 353:		/* #define RPL_NAMREPLY         353 */
		funny_namreply(from, ArgList);
		break;

	case 366:		/* #define RPL_ENDOFNAMES       366 */
		{
			u_char	*tmp = NULL,
				*chan;

			PasteArgs(ArgList, 0);
			malloc_strcpy(&tmp, ArgList[0]);
			chan = next_arg(tmp, 0);
			flag = do_hook(current_numeric(), "%s %s", from, ArgList[0]);
			
			if (flag &&
			    channel_mode_lookup(chan, CHAN_NAMES | CHAN_MODE, 0) &&
			    get_int_var(SHOW_END_OF_MSGS_VAR) && flag)
				display_msg(from, ArgList);

			new_free(&tmp);
		}
		break;

	case 381: 		/* #define RPL_YOUREOPER        381 */
		PasteArgs(ArgList, 0);
		if (do_hook(current_numeric(), "%s %s", from, *ArgList))
			display_msg(from, ArgList);
		server_set_operator(parsing_server(), 1);
		update_all_status();	/* fix the status line */
		break;

	case 401:		/* #define ERR_NOSUCHNICK       401 */
		no_such_nickname(from, ArgList);
		break;

	case 405:		/* #define ERR_TOOMANYCHANNELS  405 */
		remove_channel(ArgList[0], parsing_server());
		break;
		
	case 421:		/* #define ERR_UNKNOWNCOMMAND   421 */
		if (check_screen_redirect(ArgList[0]))
			break;
		if (check_wait_command(ArgList[0]))
			break;
		PasteArgs(ArgList, 0);
		flag = do_hook(current_numeric(), "%s %s", from, *ArgList);
		if (!my_strncmp("ISON", *ArgList, 4) || !my_strncmp("USERHOST",
		    *ArgList, 8))
		{
			server_set_2_6_2(parsing_server(), 0);
			convert_to_whois();
		}
		else if (flag)
			display_msg(from, ArgList);
		break;

	case 432:		/* #define ERR_ERRONEUSNICKNAME 432 */
	case 433:		/* #define ERR_NICKNAMEINUSE    433 */ 
		PasteArgs(ArgList, 0);
		if (do_hook(current_numeric(), "%s %s", from, *ArgList))
			display_msg(from, ArgList);
		reset_nickname(from);
		break;

	case 437:		/* #define ERR_UNAVAILRESOURCE  437 */
		PasteArgs(ArgList, 0);
		if (do_hook(current_numeric(), "%s %s", from, *ArgList))
			display_msg(from, ArgList);
		if (!is_channel(*ArgList))
			reset_nickname(from);
		break;

	case 463:		/* #define ERR_NOPERMFORHOST    463 */
		display_msg(from, ArgList);
		close_server(parsing_server(), empty_string());
		window_check_servers();
		if (!connected_to_server())
			get_connected(parsing_server() + 1);
		break;

	case 464:		/* #define ERR_PASSWDMISMATCH   464 */
		PasteArgs(ArgList, 0);
		flag = do_hook(current_numeric(), "%s %s", from, ArgList[0]);
		if (server_get_oper_command())
		{
			if (flag)
				display_msg(from, ArgList);
		}
		else
			get_password();
		break;

	case 465:		/* #define ERR_YOUREBANNEDCREEP 465 */
		{
			int	klined_server = parsing_server();

			PasteArgs(ArgList, 0);
			if (do_hook(current_numeric(), "%s %s", from, ArgList[0]))
				display_msg(from, ArgList);
			close_server(parsing_server(), empty_string());
			window_check_servers();
			if (number_of_servers() > 1)
				remove_from_server_list(klined_server);
			if (!connected_to_server())
				say("You are not connected to a server. Use /SERVER to connect.");
			break;
		}

	case 471:		/* #define ERR_CHANNELISFULL    471 */
	case 473:		/* #define ERR_INVITEONLYCHAN   473 */
	case 474:		/* #define ERR_BANNEDFROMCHAN   474 */
	case 475: 		/* #define ERR_BADCHANNELKEY    475 */
	case 476:		/* #define ERR_BADCHANMASK      476 */
		cannot_join_channel(from, ArgList);
		break;

	case 484:		/* #define ERR_RESTRICTED       484 */
		if (do_hook(current_numeric(), "%s %s", from, *ArgList))
			display_msg(from, ArgList);
		server_set_flag(parsing_server(), USER_MODE_R, 1);
		break;

		/*
		 * The following accumulates the remaining arguments
		 * in ArgSpace for hook detection.  We can't use
		 * PasteArgs here because we still need the arguments
		 * separated for use elsewhere.
		 */
	default:
		{
			u_char	*ArgSpace = NULL;
			int	i,
				do_message_from = 0;
			size_t	len;

			for (i = len = 0; ArgList[i]; len += my_strlen(ArgList[i++]))
				;
			len += (i - 1);
			ArgSpace = new_malloc(len + 1);
			ArgSpace[0] = '\0';
			/* this is cheating */
			if (ArgList[0] && is_channel(ArgList[0]))
				do_message_from = 1;
			for (i = 0; ArgList[i]; i++)
			{
				if (i)
					my_strcat(ArgSpace, " ");
				my_strcat(ArgSpace, ArgList[i]);
			}
			if (do_message_from)
				message_from(ArgList[0], LOG_CRAP);
			i = do_hook(current_numeric(), "%s %s", from, ArgSpace);
			new_free(&ArgSpace);
			if (do_message_from)
				restore_message_from();
			if (i == 0)
				goto done;
			none_of_these = 1;
		}
	}
	/* the following do not hurt the ircII if intercepted by a hook */
	if (none_of_these)
	{
		switch (comm)
		{
		case 221: 		/* #define RPL_UMODEIS          221 */
			put_it("%s Your user mode is \"%s\"", numeric_banner(),
				ArgList[0]);
			break;

		case 242:		/* #define RPL_STATSUPTIME      242 */
			PasteArgs(ArgList, 0);
			if (from && !my_strnicmp(server_get_itsname(parsing_server()),
			    from, my_strlen(server_get_itsname(parsing_server()))))
				from = NULL;
			if (from)
				put_it("%s %s from (%s)", numeric_banner(),
					*ArgList, from);
			else
				put_it("%s %s", numeric_banner(), *ArgList);
			break;

		case 332:		/* #define RPL_TOPIC            332 */
			channel_topic(from, ArgList);
			break;

		case 351:		/* #define RPL_VERSION          351 */
			version(from, ArgList);
			break;

		case 364:		/* #define RPL_LINKS            364 */
			if (ArgList[2])
			{
				PasteArgs(ArgList, 2);
				put_it("%s %-20s %-20s %s", numeric_banner(),
					ArgList[0], ArgList[1], ArgList[2]);
			}
			else
			{
				PasteArgs(ArgList, 1);
				put_it("%s %-20s %s", numeric_banner(),
					ArgList[0], ArgList[1]);
			}
			break;

		case 372:		/* #define RPL_MOTD             372 */
			if (!get_int_var(SUPPRESS_SERVER_MOTD_VAR) ||
			    !server_get_motd(parsing_server()))
			{
				PasteArgs(ArgList, 0);
				put_it("%s %s", numeric_banner(), ArgList[0]);
			}
			break;

		case 375:		/* #define RPL_MOTDSTART        375 */
			if (!get_int_var(SUPPRESS_SERVER_MOTD_VAR) ||
			    !server_get_motd(parsing_server()))
			{
				PasteArgs(ArgList, 0);
				put_it("%s %s", numeric_banner(), ArgList[0]);
			}
			break;

		case 376:		/* #define RPL_ENDOFMOTD        376 */
			if (server_get_attempting_to_connect(parsing_server()))
				got_initial_version(UP("*** Your host is broken and not running any version"));
			if (get_int_var(SHOW_END_OF_MSGS_VAR) &&
			    (!get_int_var(SUPPRESS_SERVER_MOTD_VAR) ||
			    !server_get_motd(parsing_server())))
			{
				PasteArgs(ArgList, 0);
				put_it("%s %s", numeric_banner(), ArgList[0]);
			}
			server_set_motd(parsing_server(), 0);
			break;

		case 384:		/* #define RPL_MYPORTIS         384 */
			PasteArgs(ArgList, 0);
			put_it("%s %s %s", numeric_banner(), ArgList[0], user);
			break;

		case 385:		/* #define RPL_NOTOPERANYMORE   385 */
			server_set_operator(parsing_server(), 0);
			display_msg(from, ArgList);
			update_all_status();
			break;

		case 403:		/* #define ERR_NOSUCHCHANNEL    403 */
			not_valid_channel(from, ArgList);
			break;

		case 451:		/* #define ERR_NOTREGISTERED    451 */
	/*
	 * Sometimes the server doesn't catch the USER line, so
	 * here we send a simplified version again  -lynx 
	 */
			send_to_server("USER %s %s . :%s", my_username(),
				irc_umode(), my_realname());
			send_to_server("NICK %s",
				server_get_nickname(parsing_server()));
			break;

		case 462:		/* #define ERR_ALREADYREGISTRED 462 */
			display_msg(from, ArgList);
			break;

#define RPL_CLOSEEND         363
#define RPL_SERVLISTEND      235
		case 315:		/* #define RPL_ENDOFWHO         315 */
		case 323:               /* #define RPL_LISTEND          323 */
			funny_print_widelist();

		case 219:		/* #define RPL_ENDOFSTATS       219 */
		case 232:		/* #define RPL_ENDOFSERVICES    232 */
		case 365:		/* #define RPL_ENDOFLINKS       365 */
		case 368:		/* #define RPL_ENDOFBANLIST     368 */
		case 369:		/* #define RPL_ENDOFWHOWAS      369 */
		case 374:		/* #define RPL_ENDOFINFO        374 */
#if 0	/* this case needs special handing - see above */
		case 376:		/* #define RPL_ENDOFMOTD        376 */
#endif /* 0 */
		case 394:		/* #define RPL_ENDOFUSERS       394 */
			if (!get_int_var(SHOW_END_OF_MSGS_VAR))
				break;
		default:
			display_msg(from, ArgList);
		}
	}
	set_lastlog_msg_level(lastlog_level);
done:
	restore_message_from();
}
Example #24
0
/**
 * Connect to a remote SIP useragent
 *
 * @param sessp     Pointer to allocated SIP Session
 * @param sock      SIP Session socket
 * @param to_uri    To SIP uri
 * @param from_name From display name
 * @param from_uri  From SIP uri
 * @param cuser     Contact username or URI
 * @param routev    Outbound route vector
 * @param routec    Outbound route vector count
 * @param ctype     Session content-type
 * @param desc      Content description (e.g. SDP)
 * @param authh     SIP Authentication handler
 * @param aarg      Authentication handler argument
 * @param aref      True to mem_ref() aarg
 * @param offerh    Session offer handler
 * @param answerh   Session answer handler
 * @param progrh    Session progress handler
 * @param estabh    Session established handler
 * @param infoh     Session info handler
 * @param referh    Session refer handler
 * @param closeh    Session close handler
 * @param arg       Handler argument
 * @param fmt       Formatted strings with extra SIP Headers
 *
 * @return 0 if success, otherwise errorcode
 */
int sipsess_connect(struct sipsess **sessp, struct sipsess_sock *sock,
		    const char *to_uri, const char *from_name,
		    const char *from_uri, const char *cuser,
		    const char *routev[], uint32_t routec,
		    const char *ctype, struct mbuf *desc,
		    sip_auth_h *authh, void *aarg, bool aref,
		    sipsess_offer_h *offerh, sipsess_answer_h *answerh,
		    sipsess_progr_h *progrh, sipsess_estab_h *estabh,
		    sipsess_info_h *infoh, sipsess_refer_h *referh,
		    sipsess_close_h *closeh, void *arg, const char *fmt, ...)
{
	struct sipsess *sess;
	int err;

	if (!sessp || !sock || !to_uri || !from_uri || !cuser || !ctype)
		return EINVAL;

	err = sipsess_alloc(&sess, sock, cuser, ctype, desc, authh, aarg, aref,
			    offerh, answerh, progrh, estabh, infoh, referh,
			    closeh, arg);
	if (err)
		return err;

	/* Custom SIP headers */
	if (fmt) {
		va_list ap;

		sess->hdrs = mbuf_alloc(256);
		if (!sess->hdrs) {
			err = ENOMEM;
			goto out;
		}

		va_start(ap, fmt);
		err = mbuf_vprintf(sess->hdrs, fmt, ap);
		sess->hdrs->pos = 0;
		va_end(ap);

		if (err)
			goto out;
	}

	sess->owner = true;

	err = sip_dialog_alloc(&sess->dlg, to_uri, to_uri, from_name,
			       from_uri, routev, routec);
	if (err)
		goto out;

	hash_append(sock->ht_sess,
		    hash_joaat_str(sip_dialog_callid(sess->dlg)),
		    &sess->he, sess);

	err = invite(sess);
	if (err)
		goto out;

 out:
	if (err)
		mem_deref(sess);
	else
		*sessp = sess;

	return err;
}
void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData)
{
    TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_INVITE");

    uint64 playerGuid = _player->GetGUID();

    uint64 eventId;
    uint64 inviteId;
    std::string name;
    uint16 length;
    bool isPreInvite;
    bool isGuildEvent;

    uint64 inviteeGuid = 0;
    uint32 inviteeTeam = 0;
    uint32 inviteeGuildId = 0;

    recvData >> eventId >> inviteId;
    isPreInvite = recvData.ReadBit();
    length = recvData.ReadBits(9);
    isGuildEvent = recvData.ReadBit();
    name = recvData.ReadString(length);

    if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str()))
    {
        // Invitee is online
        inviteeGuid = player->GetGUID();
        inviteeTeam = player->GetTeam();
        inviteeGuildId = player->GetGuildId();
    }
    else
    {
        // Invitee offline, get data from database
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME);
        stmt->setString(0, name);
        if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
        {
            Field* fields = result->Fetch();
            inviteeGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
            inviteeTeam = Player::TeamForRace(fields[1].GetUInt8());
            inviteeGuildId = Player::GetGuildIdFromDB(inviteeGuid);
        }
    }

    if (!inviteeGuid)
    {
        sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_PLAYER_NOT_FOUND);
        return;
    }

    if (_player->GetTeam() != inviteeTeam && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR))
    {
        sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NOT_ALLIED);
        return;
    }

    if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = " UI64FMTD " AND friend = " UI64FMTD, inviteeGuid, playerGuid))
    {
        Field* fields = result->Fetch();
        if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED)
        {
            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, name.c_str());
            return;
        }
    }

    if (!isPreInvite)
    {
        if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId))
        {
            // DEFAULT_STATUS_TIME is 01/01/2000 00:00:00 - default response time
            CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, inviteeGuid, playerGuid, DEFAULT_STATUS_TIME, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");
            sCalendarMgr->AddInvite(calendarEvent, invite);
        }
        else
            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_EVENT_INVALID);
    }
    else
    {
        // DEFAULT_STATUS_TIME is 01/01/2000 00:00:00 - default response time
        CalendarInvite invite(inviteId, 0, inviteeGuid, playerGuid, DEFAULT_STATUS_TIME, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");
        sCalendarMgr->SendCalendarEventInvite(invite);
    }
}
Example #26
0
static void invite_resp_handler(int err, const struct sip_msg *msg, void *arg)
{
	struct sipsess *sess = arg;
	struct mbuf *desc = NULL;

	if (err || sip_request_loops(&sess->ls, msg->scode))
		goto out;

	if (msg->scode < 200) {
		sess->progrh(msg, sess->arg);
		return;
	}
	else if (msg->scode < 300) {

		sess->hdrs = mem_deref(sess->hdrs);

		err = sip_dialog_create(sess->dlg, msg);
		if (err)
			goto out;

		if (sess->sent_offer)
			err = sess->answerh(msg, sess->arg);
		else {
			sess->modify_pending = false;
			err = sess->offerh(&desc, msg, sess->arg);
		}

	int err2 = sipsess_ack(sess->sock, sess->dlg, msg->cseq.num,
				   sess->auth, sess->ctype, desc);
    if (err2)
        printf("sipsess - sent first ACK for call %.*s, got err %d (%s)\n", msg->callid.l, msg->callid.p, err2, strerror(err2));
    err |= err2;

		sess->established = true;
		mem_deref(desc);

		if (err || sess->terminated)
			goto out;

		if (sess->modify_pending)
			(void)sipsess_reinvite(sess, true);
		else
			sess->desc = mem_deref(sess->desc);

		sess->estabh(msg, sess->arg);
		return;
	}
	else if (msg->scode < 400) {

		/* Redirect to first Contact */

		if (sess->terminated)
			goto out;

		err = sip_dialog_update(sess->dlg, msg);
		if (err)
			goto out;

		err = invite(sess);
		if (err)
			goto out;

		return;
	}
	else {
		if (sess->terminated)
			goto out;

		switch (msg->scode) {

		case 401:
		case 407:
			err = sip_auth_authenticate(sess->auth, msg);
			if (err) {
				err = (err == EAUTH) ? 0 : err;
				break;
			}

			err = invite(sess);
			if (err)
				break;

			return;
		}
	}

 out:
	if (!sess->terminated)
		sipsess_terminate(sess, err, msg);
	else
		mem_deref(sess);
}
Example #27
0
void du_clavier(void)
{
    int i,choix;

    info("On travaille sur un intervalle (x[1],x[n])");
    invite("Entrez n:\t");
    scanf("%d",&n);
    vider_stdin();

    x = MALLOC(double,n);
    y = MALLOC(double,n);

    if((x == NULL) || (y == NULL))
    {
        erreur("Impossible d\'allouer la mémoire pour x et y (dans du_clavier())");
        perror("Description système de l\'erreur");
        menu();
    }

    saisie_donnees();

    while(verifier() == 0)
    {
        erreur("Les valeurs des xi ne sont pas deux a deux distinctes.");
        info("Vous pouvez :\n\t1 - Recommencer la saisie\n\t2 - Abandonner");
        invite("Votre choix :");
        scanf("%d",&choix);
        vider_stdin();

        if(choix == 1)
        {
            saisie_donnees();
        } else {
            menu();
            return; // plus rien à faire ici
        }
    }

    // Suggérer à l'utilisateur d'enrégistrer les données
    info("Un instant, avant de continuer il est *recommandé* de sauvegarder vos données dans un fichier.");
    invite("Sauvegarder? (0 = non, 1 = oui):");
    scanf("%d", &choix);
    vider_stdin();

    if(choix == 1)
    {
        info("Sage décision!");

        donnees = open_w(quel_nom(), 0);

        if(!donnees)
        {
            if(!OF_abandon) // pas d'abandon, c'est donc une erreur système
            {
                erreur("Erreur fatale, impossible de créer le fichier: données non sauvegardées");
                perror("Description système de l\'erreur");
            }
        } else {
            for(i = 0; i < n; i ++)
            {
                fprintf(donnees, "%lf\t%lf\n", x[i], y[i]);
            }

            fclose(donnees);
            info("[Données sauvagardées]");
            pause();
        }
    } // fin de sauvegarde des données.

    menu();
}
Example #28
0
int Irc::Session::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: connected(); break;
        case 1: welcomed(); break;
        case 2: reconnecting(); break;
        case 3: disconnected(); break;
        case 4: bufferAdded((*reinterpret_cast< Irc::Buffer*(*)>(_a[1]))); break;
        case 5: bufferRemoved((*reinterpret_cast< Irc::Buffer*(*)>(_a[1]))); break;
        case 6: capabilitiesListed((*reinterpret_cast< const QStringList(*)>(_a[1]))); break;
        case 7: capabilitiesAcked((*reinterpret_cast< const QStringList(*)>(_a[1]))); break;
        case 8: capabilitiesNotAcked((*reinterpret_cast< const QStringList(*)>(_a[1]))); break;
        case 9: msgJoined((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 10: msgParted((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break;
        case 11: msgQuit((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 12: msgNickChanged((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 13: msgModeChanged((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3])),(*reinterpret_cast< const QString(*)>(_a[4]))); break;
        case 14: msgTopicChanged((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break;
        case 15: msgInvited((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break;
        case 16: msgKicked((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3])),(*reinterpret_cast< const QString(*)>(_a[4]))); break;
        case 17: msgMessageReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break;
        case 18: msgNoticeReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break;
        case 19: msgCtcpRequestReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 20: msgCtcpReplyReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 21: msgCtcpActionReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break;
        case 22: msgNumericMessageReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< uint(*)>(_a[2])),(*reinterpret_cast< const QStringList(*)>(_a[3]))); break;
        case 23: msgUnknownMessageReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QStringList(*)>(_a[2]))); break;
        case 24: connectToServer((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< quint16(*)>(_a[2]))); break;
        case 25: connectToServer((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 26: connectToServer(); break;
        case 27: reconnectToServer(); break;
        case 28: disconnectFromServer(); break;
        case 29: { bool _r = raw((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 30: { bool _r = motd();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 31: { bool _r = join((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 32: { bool _r = join((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 33: { bool _r = part((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 34: { bool _r = part((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 35: { bool _r = quit((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 36: { bool _r = quit();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 37: { bool _r = names((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 38: { bool _r = list((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 39: { bool _r = list();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 40: { bool _r = whois((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 41: { bool _r = whowas((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 42: { bool _r = mode((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 43: { bool _r = mode((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 44: { bool _r = topic((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 45: { bool _r = topic((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 46: { bool _r = invite((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 47: { bool _r = kick((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 48: { bool _r = kick((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 49: { bool _r = message((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 50: { bool _r = notice((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 51: { bool _r = ctcpAction((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 52: { bool _r = ctcpRequest((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 53: { bool _r = ctcpReply((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 54: requestCapabilities((*reinterpret_cast< const QStringList(*)>(_a[1]))); break;
        case 55: clearCapabilities(); break;
        case 56: { bool _r = sendRaw((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 57: { bool _r = cmdJoin((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 58: { bool _r = cmdJoin((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 59: { bool _r = cmdPart((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 60: { bool _r = cmdPart((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 61: { bool _r = cmdQuit((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 62: { bool _r = cmdQuit();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 63: { bool _r = cmdNames((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 64: { bool _r = cmdList((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 65: { bool _r = cmdList();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 66: { bool _r = cmdWhois((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 67: { bool _r = cmdMode((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 68: { bool _r = cmdMode((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 69: { bool _r = cmdTopic((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 70: { bool _r = cmdTopic((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 71: { bool _r = cmdInvite((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 72: { bool _r = cmdKick((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 73: { bool _r = cmdKick((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 74: { bool _r = cmdMessage((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 75: { bool _r = cmdNotice((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 76: { bool _r = cmdCtcpAction((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 77: { bool _r = cmdCtcpRequest((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 78: { bool _r = cmdCtcpReply((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 79: d_func()->_q_connected(); break;
        case 80: d_func()->_q_disconnected(); break;
        case 81: d_func()->_q_reconnect(); break;
        case 82: d_func()->_q_error(); break;
        case 83: d_func()->_q_state((*reinterpret_cast< QAbstractSocket::SocketState(*)>(_a[1]))); break;
        case 84: d_func()->_q_readData(); break;
        case 85: d_func()->_q_joined((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 86: d_func()->_q_parted((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 87: d_func()->_q_quit((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 88: d_func()->_q_nickChanged((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 89: d_func()->_q_modeChanged((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break;
        case 90: d_func()->_q_topicChanged((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 91: d_func()->_q_invited((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break;
        case 92: d_func()->_q_kicked((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break;
        case 93: d_func()->_q_messageReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 94: d_func()->_q_noticeReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 95: d_func()->_q_ctcpRequestReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 96: d_func()->_q_ctcpReplyReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 97: d_func()->_q_ctcpActionReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 98: d_func()->_q_numericMessageReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< uint(*)>(_a[2])),(*reinterpret_cast< const QStringList(*)>(_a[3]))); break;
        case 99: d_func()->_q_unknownMessageReceived((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QStringList(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 100;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QStringList*>(_v) = autoJoinChannels(); break;
        case 1: *reinterpret_cast< int*>(_v) = autoReconnectDelay(); break;
        case 2: *reinterpret_cast< QByteArray*>(_v) = encoding(); break;
        case 3: *reinterpret_cast< QString*>(_v) = host(); break;
        case 4: *reinterpret_cast< QString*>(_v) = ident(); break;
        case 5: *reinterpret_cast< QString*>(_v) = nick(); break;
        case 6: *reinterpret_cast<int*>(_v) = QFlag(options()); break;
        case 7: *reinterpret_cast< QString*>(_v) = password(); break;
        case 8: *reinterpret_cast< quint16*>(_v) = port(); break;
        case 9: *reinterpret_cast< QString*>(_v) = realName(); break;
        case 10: *reinterpret_cast< QStringList*>(_v) = supportedCapabilities(); break;
        case 11: *reinterpret_cast< QStringList*>(_v) = enabledCapabilities(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setAutoJoinChannels(*reinterpret_cast< QStringList*>(_v)); break;
        case 1: setAutoReconnectDelay(*reinterpret_cast< int*>(_v)); break;
        case 2: setEncoding(*reinterpret_cast< QByteArray*>(_v)); break;
        case 3: setHost(*reinterpret_cast< QString*>(_v)); break;
        case 4: setIdent(*reinterpret_cast< QString*>(_v)); break;
        case 5: setNick(*reinterpret_cast< QString*>(_v)); break;
        case 6: setOptions(QFlag(*reinterpret_cast<int*>(_v))); break;
        case 7: setPassword(*reinterpret_cast< QString*>(_v)); break;
        case 8: setPort(*reinterpret_cast< quint16*>(_v)); break;
        case 9: setRealName(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #29
0
/**
 * Event handler pro aktivaci položky v seznamu hráčů
 * 
 * @param event
 */
void LobbyWindow::onPlayersActivate(wxListEvent &event)
{
    invite(event.GetText());
}
void WorldSession::HandleCalendarEventInvite(WorldPackets::Calendar::CalendarEventInvite& calendarEventInvite)
{
    ObjectGuid playerGuid = _player->GetGUID();

    ObjectGuid inviteeGuid;
    uint32 inviteeTeam = 0;
    ObjectGuid::LowType inviteeGuildId = UI64LIT(0);

    if (Player* player = ObjectAccessor::FindConnectedPlayerByName(calendarEventInvite.Name))
    {
        // Invitee is online
        inviteeGuid = player->GetGUID();
        inviteeTeam = player->GetTeam();
        inviteeGuildId = player->GetGuildId();
    }
    else
    {
        // Invitee offline, get data from database
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME);
        stmt->setString(0, calendarEventInvite.Name);
        if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
        {
            Field* fields = result->Fetch();
            inviteeGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
            inviteeTeam = Player::TeamForRace(fields[1].GetUInt8());
            inviteeGuildId = Player::GetGuildIdFromDB(inviteeGuid);
        }
    }

    if (!inviteeGuid)
    {
        sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_PLAYER_NOT_FOUND);
        return;
    }

    if (_player->GetTeam() != inviteeTeam && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR))
    {
        sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NOT_ALLIED);
        return;
    }

    if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = %u AND friend = %u", inviteeGuid.GetCounter(), playerGuid.GetCounter()))
    {
        Field* fields = result->Fetch();
        if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED)
        {
            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, calendarEventInvite.Name.c_str());
            return;
        }
    }

    if (!calendarEventInvite.Creating)
    {
        if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventInvite.EventID))
        {
            if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == inviteeGuildId)
            {
                // we can't invite guild members to guild events
                sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES);
                return;
            }

            CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEventInvite.EventID, inviteeGuid, playerGuid, CALENDAR_DEFAULT_RESPONSE_TIME, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");
            sCalendarMgr->AddInvite(calendarEvent, invite);
        }
        else
            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_EVENT_INVALID);
    }
    else
    {
        if (calendarEventInvite.IsSignUp && inviteeGuildId == _player->GetGuildId())
        {
            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES);
            return;
        }

        CalendarInvite invite(sCalendarMgr->GetFreeInviteId(), NULL, inviteeGuid, playerGuid, CALENDAR_DEFAULT_RESPONSE_TIME, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");
        sCalendarMgr->SendCalendarEventInvite(invite);
    }
}