Exemplo n.º 1
0
int qmlRegisterTypeEnums(const char *qmlName)
{
    QByteArray name(T::staticMetaObject.className());

    QByteArray pointerName(name + '*');
    QByteArray listName("QDeclarativeListProperty<" + name + ">");

    QDeclarativePrivate::RegisterType type = {
        0,

        qRegisterMetaType<T *>(pointerName.constData()),
        qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
        0, 0,

        "Qt", 4, 6, qmlName, &T::staticMetaObject,

        QDeclarativePrivate::attachedPropertiesFunc<T>(),
        QDeclarativePrivate::attachedPropertiesMetaObject<T>(),

        QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
        QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
        QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),

        0, 0,

        0
    };

    return QDeclarativePrivate::registerType(type);
}
Exemplo n.º 2
0
void AuthenticationServer::HandleAuthCharacter( MsgEntry* me, Client *client )
{
    psCharacterPickerMessage charpick( me );
    if (!charpick.valid)
    {
        Debug1(LOG_NET,me->clientnum,"Mangled psCharacterPickerMessage received.\n");
        return;
    } 

    psCharacterList *charlist = psserver->CharacterLoader.LoadCharacterList( client->GetAccountID());
    
    if (!charlist)
    {
        Error1("Could not load Character List for account! Rejecting client!\n");
        psserver->RemovePlayer( me->clientnum, "Could not load the list of characters for your account.  Please contact a PS Admin for help.");        
        return;
    } 

    int i;
    for (i=0;i<MAX_CHARACTERS_IN_LIST;i++)
    {
        if (charlist->GetEntryValid(i))
        {
            // Trim out whitespaces from name
            charpick.characterName.Trim();
            csString listName( charlist->GetCharacterFullName(i) );
            listName.Trim();
                                            
            if ( charpick.characterName == listName )
            {
                 client->SetPID(charlist->GetCharacterID(i));
                 // Set client name in code to just firstname as other code depends on it
                 client->SetName(charlist->GetCharacterName(i));
                 psCharacterApprovedMessage out( me->clientnum );
                 out.SendMessage();
                 break;
            }                     
        }
    }

    // cache will auto-delete this ptr if it times out
    CacheManager::GetSingleton().AddToCache(charlist, CacheManager::GetSingleton().MakeCacheName("list", client->GetAccountID().Unbox()),120);
}
Exemplo n.º 3
0
int main(int argc, const char *argv[])
{ int a;
    FILE *pFile = fopen("movielist.txt", "r");
	while (!feof(pFile)) {
                 cbuf[0]='\0';
		fgets(cbuf, sizeof(cbuf), pFile);
                
		get_Movielist(cbuf); 
	}

      
  while(1){  
     printf("1.listName\n");
     printf("2.listDirector\n");
     printf("3.accordingtoYear\n");
     printf("4.accordingtoDirector\n");
     printf("5.Display all\n");
     printf("Please choose:");
     scanf("%d",&a);

   switch(a)
  { case 1: listName();break;

   case 2:listDirector();break;

   case 3:accordingtoYear();break;

   case 4:accordingtoDirector();break;

   case 5:display();break;
    default:exit(0);
   }
    
}

   return 0;
}
Exemplo n.º 4
0
int Server::appendGroupMsg(shared_ptr<IMChat::UnreadMsgRequest> ptrRequest, IMChat::UnreadMsgResponse&  response)
{
	auto ptrContext = m_redis.GetContext();
	redisReply* ptrReply = NULL;

	string keyGroupSet("groupSet:");
	keyGroupSet += ptrRequest->userid();

	string keyNumber("unreadNumber:");
	keyNumber += ptrRequest->userid();

	keyNumber += ":*";

	//查询各个群未读消息数目;
	//COMMAND: SORT groupSet:14006 GET # GET unreadNumber:14006:*

	vector<string> numberData;
	ptrReply = static_cast<redisReply*>(redisCommand(ptrContext, "SORT %s GET # GET %s", keyGroupSet.c_str(), keyNumber.c_str()));
	if (NULL != ptrReply && REDIS_REPLY_ARRAY == ptrReply->type && 0 != ptrReply->elements)
	{
		for (size_t i = 0; i < ptrReply->elements; i++)
		{
			numberData.push_back(string(ptrReply->element[i]->str, ptrReply->element[i]->len));
		}
	}
	freeReplyObject(ptrReply);
	for (int i = 0; i < numberData.size()/2; i++)
	{
		if (numberData[2 * i + 1].compare("0") != 0)
		{
			//vector 数据第一个是groupId第二个是未读群消息数目;
			string listName("groupMsg:");
			listName += numberData[2 * i];
			redisAppendCommand(ptrContext, "LRANGE %s %d %s", listName.c_str(), 0, numberData[2 * i + 1]);
		}
	}
	//未读消息数;
	int nMsgNumber = 0;
	for (size_t i = 0; i < numberData.size()/2; i++)
	{
		if (numberData[2 * i + 1].compare("0") != 0)
		{
			redisGetReply(ptrContext, reinterpret_cast<void**>(&ptrReply));
			if (NULL != ptrReply && REDIS_REPLY_ARRAY == ptrReply->type && 0 != ptrReply->elements)
			{
				for (size_t i = 0; i < ptrReply->elements; i++)
				{
					//添加repeated数据;
					response.add_msgdata()->assign(ptrReply->element[i]->str, ptrReply->element[i]->len);
				}
				nMsgNumber += ptrReply->elements;
			}
			freeReplyObject(ptrReply);
		}
	}
	//将未读消息数目置0;
	for (size_t i = 0; i < numberData.size() / 2; i++)
	{
		if (numberData[2 * i + 1].compare("0") != 0)
		{
			//Key unreadNumber:userid:groupid
			string key("unreadNumber:");
			key += ptrRequest->userid();
			key += ':';
			key += numberData[2 * i];
			m_redis.Set(key, "0");
		}
	}
	return nMsgNumber;
}