Exemplo n.º 1
0
void ResourceResponse::platformLazyInit()
{
    if (m_isUpToDate)
        return;
    m_isUpToDate = true;

    if (m_isNull) {
        ASSERT(!m_cfResponse.get());
        return;
    }

    // FIXME: We may need to do MIME type sniffing here (unless that is done in CFURLResponseGetMIMEType).

    m_url = CFURLResponseGetURL(m_cfResponse.get());
    m_mimeType = CFURLResponseGetMIMEType(m_cfResponse.get());
    m_expectedContentLength = CFURLResponseGetExpectedContentLength(m_cfResponse.get());
    m_textEncodingName = CFURLResponseGetTextEncodingName(m_cfResponse.get());

    // Workaround for <rdar://problem/8757088>, can be removed once that is fixed.
    unsigned textEncodingNameLength = m_textEncodingName.length();
    if (textEncodingNameLength >= 2 && m_textEncodingName[0U] == '"' && m_textEncodingName[textEncodingNameLength - 1] == '"')
        m_textEncodingName = m_textEncodingName.substring(1, textEncodingNameLength - 2);

    m_lastModifiedDate = toTimeT(CFURLResponseGetLastModifiedDate(m_cfResponse.get()));

    RetainPtr<CFStringRef> suggestedFilename(AdoptCF, CFURLResponseCopySuggestedFilename(m_cfResponse.get()));
    m_suggestedFilename = suggestedFilename.get();

    CFHTTPMessageRef httpResponse = CFURLResponseGetHTTPResponse(m_cfResponse.get());
    if (httpResponse) {
        m_httpStatusCode = CFHTTPMessageGetResponseStatusCode(httpResponse);

        RetainPtr<CFStringRef> statusLine(AdoptCF, CFHTTPMessageCopyResponseStatusLine(httpResponse));
        m_httpStatusText = extractReasonPhraseFromHTTPStatusLine(statusLine.get());

        RetainPtr<CFDictionaryRef> headers(AdoptCF, CFHTTPMessageCopyAllHeaderFields(httpResponse));
        CFIndex headerCount = CFDictionaryGetCount(headers.get());
        Vector<const void*, 128> keys(headerCount);
        Vector<const void*, 128> values(headerCount);
        CFDictionaryGetKeysAndValues(headers.get(), keys.data(), values.data());
        for (int i = 0; i < headerCount; ++i)
            m_httpHeaderFields.set((CFStringRef)keys[i], (CFStringRef)values[i]);
    } else
        m_httpStatusCode = 0;
}
Exemplo n.º 2
0
Arquivo: equip.c Projeto: mudchina/fy4
int wear() {
        object owner;
        mapping armor_prop, applied_prop;
        string *apply, type; 
        // Only character object can wear armors.
        if(!objectp(owner = environment()) || !owner->is_character()) {
                return 0;
        }
        
        // If already worn, just recognize it.
        if(query("equipped")) {
                return 1;
        }
        
        // Check if we have "armor_prop" defined.
        if(!mapp(armor_prop = query("armor_prop"))) {
                return notify_fail("你只能穿戴可当作护具的东西。\n");
        }
        
        // Check for armor_type
        type = query("armor_type");
        if(!stringp(type)) {
                return notify_fail("你只能穿戴可当作护具的东西。\n");
        }
        if(owner->query_temp("armor/" + type)) {
                return notify_fail("你已经穿戴了同类型的护具了。\n");
        }
        if(type == "shield") {
                if(owner->query_temp("left_hand") && owner->query_temp("right_hand")) {
                        return notify_fail("你必须至少空出一只手来使用武器。\n");
           }
                if(!objectp(owner->query_temp("left_hand"))) {
                        owner->set_temp("left_hand",this_object());
                } else if(!objectp(owner->query_temp("right_hand"))) {
                        owner->set_temp("right_hand",this_object());
                }
        }
        owner->set_temp("armor/" + type, this_object());
        
        // Add armor prop to charactor apply prop.
        apply = keys(armor_prop);
        applied_prop = owner->query_temp("apply");
        if(!mapp(applied_prop)) {
                applied_prop = ([]);
        }
Exemplo n.º 3
0
// This is the interface to the intermud channels
void send_msg(string channel, string id, string name, string msg, int emoted,
	mixed filter)
{
	string *names;
	int i;
	mapping muds;
	mapping svcs;
	mapping minfo;

//	if( !this_player()		// Prevent from being called by ourself.
//	||	!ACCESS_CHECK(previous_object())) return;
	if( !ACCESS_CHECK(previous_object())) return;

#ifdef DEBUG
	CHANNEL_D->do_channel(this_object(), DEBUG, "prepare to send gchannel message.");
#endif
	muds = (mapping)DNS_MASTER->query_muds();
	svcs = (mapping)DNS_MASTER->query_svc();
	msg = replace_string(msg, "|", "");
	msg = replace_string(msg, "@@@", "");
	// use keys(svcs) because none of the muds not in svcs can possibley
	// receive the message
	names = keys(svcs);
	i = sizeof(names);
	while(i--)
		if( (names[i] != mud_nname())
		&&	evaluate(filter, muds[names[i]])) {
			minfo = muds[names[i]];
			if(!mapp(minfo) || !mapp(svcs[names[i]])
			|| !(svcs[names[i]]["gwizmsg"] & SVC_UDP))
				continue;
//                if( channel !="gwiz" && minfo["MUDLIB"] != "Eastern Stories" && minfo["MUDLIB"] != "A Journey to the West" )
//                        continue;

		DNS_MASTER->send_udp(minfo["HOSTADDRESS"], minfo["PORTUDP"],
				"@@@" + DNS_GCHANNEL +
				"||NAME:" + Mud_name() +
				"||PORTUDP:" + udp_port() +
				"||USRNAME:" + capitalize(id) +
				"||CNAME:" + name  +
				"||MSG:" + msg  +
				"||CHANNEL:" + channel +
				(emoted?"||EMOTE:1":"") + "@@@\n");
	}
}
Exemplo n.º 4
0
void
KeySignatureDialog::regenerateKeyCombo()
{
    if (m_explanatoryLabel)
        m_explanatoryLabel->hide();

    m_ignoreComboChanges = true;
    QString currentText = m_keyCombo->currentText();
    Rosegarden::Key::KeyList keys(Rosegarden::Key::getKeys(m_key.isMinor()));
    m_keyCombo->clear();

    std::sort(keys.begin(), keys.end(), KeyNameComparator());
    bool textSet = false;

    for (Rosegarden::Key::KeyList::iterator i = keys.begin();
            i != keys.end(); ++i) {

        QString name(strtoqstr(i->getName()));
        int space = name.indexOf(' ');
        if (space > 0)
            name = name.left(space);

        // translation required; translation from QObject::tr to pull
        // translations from (generated) InstrumentStrings.cpp, must have "note
        // name" to distinguish from keyboard shortcut, even though this is a
        // key name
        // But m_key object needed to display the key pixmap can't be easily
        // obtained from a translated key name. That's why the untranslated key
        // name is now stored in the user data associated to each QComboBox
        // item.
        QVariant untranslatedName(name);
        m_keyCombo->addItem(QObject::tr(name.toStdString().c_str(), "note name"),
                            untranslatedName);

        if (m_valid && (*i == m_key)) {
            m_keyCombo->setCurrentIndex(m_keyCombo->count() - 1);
            textSet = true;
        }
    }

    if (!textSet) {
        m_keyCombo->setEditText(currentText);
    }
    m_ignoreComboChanges = false;
}
Exemplo n.º 5
0
nomask int update_condition()
{
   mixed *cnd, err;
   int i, flag, update_flag;
   object cnd_d;

   if( !mapp(conditions) || !(i=sizeof(conditions)) ) return 0;
   cnd = keys(conditions);
   update_flag = 0;
   while(i--) {

     // In order to not casue player lost heart beat occasionally while
     // calling external condition daemons, we take careful calling
     // convention here.

     cnd_d = find_object(CONDITION_D(cnd[i]));
     if( !cnd_d ) {
        err = catch(call_other(CONDITION_D(cnd[i]), "???"));
        cnd_d = find_object(CONDITION_D(cnd[i]));

        // If we failed to load the external condition daemon, remove
        // it before we stuff log files with error messages.

        if( err || !cnd_d ) {
          log_file("condition.err",
             sprintf("Failed to load condition daemon %s, removed from %O\nError: %s\n",
               CONDITION_D(cnd[i]), this_object(), err)
          );
          map_delete(conditions, cnd[i]);
          continue;
        }
     }

     // We assume since the condition daemon is loaded successfully, the
     // calling on its update_condition() should success as well. Because
     // catch() is somewhat costly, so we don't attempt to catch possible
     // error from the call_other. It is condition daemon's reponsibility
     // that don't cause error in users's heart beat.
     // If condition daemon returns 0 (or update_condition() not defined),
     // we can just assume the condition expired and remove it.
     
     flag = call_other(cnd_d, "update_condition", this_object(), conditions[cnd[i]]);
     if( !( flag & CND_CONTINUE ) ) map_delete(conditions, cnd[i]);
     update_flag |= flag;
   }
Exemplo n.º 6
0
void ResourceRequest::doUpdateResourceRequest()
{
    if (!m_cfRequest) {
        *this = ResourceRequest();
        return;
    }

    m_url = CFURLRequestGetURL(m_cfRequest.get());

    m_cachePolicy = (ResourceRequestCachePolicy)CFURLRequestGetCachePolicy(m_cfRequest.get());
    m_timeoutInterval = CFURLRequestGetTimeoutInterval(m_cfRequest.get());
    m_firstPartyForCookies = CFURLRequestGetMainDocumentURL(m_cfRequest.get());
    if (CFStringRef method = CFURLRequestCopyHTTPRequestMethod(m_cfRequest.get())) {
        m_httpMethod = method;
        CFRelease(method);
    }
    m_allowCookies = CFURLRequestShouldHandleHTTPCookies(m_cfRequest.get());

    if (httpPipeliningEnabled())
        m_priority = toResourceLoadPriority(wkGetHTTPPipeliningPriority(m_cfRequest.get()));

    m_httpHeaderFields.clear();
    if (CFDictionaryRef headers = CFURLRequestCopyAllHTTPHeaderFields(m_cfRequest.get())) {
        CFIndex headerCount = CFDictionaryGetCount(headers);
        Vector<const void*, 128> keys(headerCount);
        Vector<const void*, 128> values(headerCount);
        CFDictionaryGetKeysAndValues(headers, keys.data(), values.data());
        for (int i = 0; i < headerCount; ++i)
            m_httpHeaderFields.set((CFStringRef)keys[i], (CFStringRef)values[i]);
        CFRelease(headers);
    }

    m_responseContentDispositionEncodingFallbackArray.clear();
    RetainPtr<CFArrayRef> encodingFallbacks(AdoptCF, copyContentDispositionEncodingFallbackArray(m_cfRequest.get()));
    if (encodingFallbacks) {
        CFIndex count = CFArrayGetCount(encodingFallbacks.get());
        for (CFIndex i = 0; i < count; ++i) {
            CFStringEncoding encoding = reinterpret_cast<CFIndex>(CFArrayGetValueAtIndex(encodingFallbacks.get(), i));
            if (encoding != kCFStringEncodingInvalidId)
                m_responseContentDispositionEncodingFallbackArray.append(CFStringConvertEncodingToIANACharSetName(encoding));
        }
    }

    m_httpBody = httpBodyFromRequest(m_cfRequest.get());
}
Exemplo n.º 7
0
void Util::SetAppropriateTimezoneL()
	{
	TUid repUid = {0x1020e4d3};
	CRepository* rep = CRepository::NewLC(repUid);
	
	// Set the date format to European
	User::LeaveIfError(rep->StartTransaction(CRepository::EConcurrentReadWriteTransaction));
	User::LeaveIfError(rep->Set(101, EDateEuropean)); // 101 is the date format reg entry
	TUint32 keys(0);
	User::LeaveIfError(rep->CommitTransaction(keys));
	
	CleanupStack::PopAndDestroy(rep);
	
	TExtendedLocale locale;
	locale.LoadSystemSettings();
	locale.GetLocale()->SetDateFormat(EDateEuropean);
	User::LeaveIfError(locale.SaveSystemSettings());
	}
Exemplo n.º 8
0
bool KeyboardOptions::load(string path)
{
	bool retVal = false;
	shared_ptr<Keys> keys(new Keys);
	if (IO::readBin(keys.get(), sizeof(Keys), path))
	{
		keyboard::m_Keys["up"] = keys->up;
		keyboard::m_Keys["down"] = keys->down;
		keyboard::m_Keys["left"] = keys->left;
		keyboard::m_Keys["right"] = keys->right;
		keyboard::m_Keys["fire_1"] = keys->fire_1;
		keyboard::m_Keys["fire_2"] = keys->fire_2;
		keyboard::m_Keys["rotate_left"] = keys->rotate_left;
		keyboard::m_Keys["rotate_right"] = keys->rotate_right;
		retVal = true;
	}
	return retVal;
}
Exemplo n.º 9
0
void send_locate_q(string who) {
    mapping info;
    string *muds;
    int i;

    i = sizeof(muds = keys(info=(mapping)DNS_MASTER->query_muds()));
    while(i--) {
        if(lower_case(muds[i]) == lower_case(Mud_name())) continue;
        DNS_MASTER->send_udp(info[muds[i]]["HOSTADDRESS"],
          info[muds[i]]["PORTUDP"], "@@@"+DNS_LOCATE_Q+
      "||NAME:"+Mud_name()+
      "||PORTUDP:"+ udp_port() +
      "||TARGET:"+lower_case(who)+
      "||ASKWIZ:"+(string)this_player()->query("name")+
        "@@@\n");
    }
    return;
}
Exemplo n.º 10
0
int do_vendor_list(string arg)
{
	mapping goods;
	string list, *name;
	int i;

	if( !mapp(goods = query("vendor_goods")) ) return 0;
	if( arg && !this_object()->id(arg) ) return 0;
	name = keys(goods);
	list = "你可以购买下列这些东西:\n";
	for(i=0; i<sizeof(name); i++)
		list += sprintf("%-30s:%s\n",
			goods[name[i]]->query("name") + "(" +
			goods[name[i]]->query("id") + ")",
			price_string(goods[name[i]]->query("value")) );
	write(list);
	return 1;	
}
Exemplo n.º 11
0
QMap<QString, T> GetMap(QString const& name)
{
   QVariant qvar(Get(name));
   QMap<QString,T> map;

   if (!qvar.isNull()) {
      QMap<QString, QVariant> variantMap(qvar.toMap());
      QStringList keys(variantMap.keys());

      QStringList::iterator iter;
      for (iter = keys.begin(); iter != keys.end(); ++iter) {
          qvar = variantMap.value(*iter);
          map.insert( (*iter), qvar.value<T>());
      }
   }

   return map;
}
Exemplo n.º 12
0
Arquivo: main.cpp Projeto: 183amir/kge
int main()
{
	kge::InitParameters	params;
	params.RendererType = kge::gfx::ERA_OpenGL;
	dev.Init(params);

	pRen	= dev.GetRenderer();
	pSnMgr	= dev.GetSceneManager();

	pCam = pSnMgr->AddCameraNode
		(
		kge::math::Vector(-75, 75, -75),	
		kge::math::Vector(0, 30, 0),		
		kge::math::Vector(0, 1, 0)	
		);

	// Load an Animated mesh is simple.
	pRen->SetTextureParams(kge::gfx::ETP_Linear);
	pMesh = pSnMgr->AddAnimatedMeshNode("../../media/models/dwarf/dwarf1.ms3d");
	for (int i = 0; i < pMesh->GetMaterialCount(); i++)
	{
		pMesh->GetMaterial(i)->shader->m_MaterialParams.eLightingType = kge::gfx::ELIT_UnLit;
		pMesh->GetMaterial(i)->shader->m_bMatParamsChanged = true;
	}

	pRen->SetClearColor(kge::gfx::Colorf(0.2,0.2,0.2,0.1));

	kge::core::Timer t;	

	while (dev.Run())
	{
		// Store the elapsed time between frames
		float fElaspedTime = t.GetTimeElapsed();

		// Check for the keys
		keys(fElaspedTime);

		pRen->BeginRendering(true, true, false);

		pSnMgr->RenderAll(fElaspedTime);

		pRen->EndRendering();
	}
}
Exemplo n.º 13
0
void KEduVocConjugation::toKVTML2(QDomElement & parent, const QString &tense)
{
    if (isEmpty()) {
        return;
    }

    QMap<int, KEduVocWordFlag::Flags> numbers;
    numbers[0] = KEduVocWordFlag::Singular;
    numbers[1] = KEduVocWordFlag::Dual;
    numbers[2] = KEduVocWordFlag::Plural;
    QMap<int, KEduVocWordFlag::Flags> persons;
    persons[0] = KEduVocWordFlag::First;
    persons[1] = KEduVocWordFlag::Second;
    persons[2] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Masculine);
    persons[3] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Feminine);
    persons[4] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Neuter);

    QDomDocument domDoc = parent.ownerDocument();

    // write the tense tag
    if (!tense.isEmpty()) {
        QDomElement tenseElement = domDoc.createElement( KVTML_TENSE );
        tenseElement.appendChild( domDoc.createTextNode(tense) );
        parent.appendChild(tenseElement);
    } else {
        qDebug() << "Saving conjugation with empty tense";
    }

    for ( int num = 0; num <= 2; ++num) {
        QDomElement numberElement = domDoc.createElement( KVTML_GRAMMATICAL_NUMBER[num] );
        for ( int person = 0; person < 5; ++person) {
            KEduVocWordFlags curFlags = numbers[num] | persons[person];

            if (keys().contains(curFlags) && !conjugation(curFlags).isEmpty()) {
                QDomElement personElement = domDoc.createElement( KVTML_GRAMMATICAL_PERSON[person] );
                numberElement.appendChild(personElement);
                conjugation(curFlags).toKVTML2(personElement);
            }
        }
        if (numberElement.hasChildNodes()) {
            parent.appendChild( numberElement );
        }
    }
}
Exemplo n.º 14
0
QStyle* AppUtil::saneStyle()
{
    if (s_saneStyle == NULL)
    {
        QSettings settings;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
        QVariant var = settings.value(SETTINGS_SLIDERSTYLE, QString("Cleanlooks"));
#else
        QVariant var = settings.value(SETTINGS_SLIDERSTYLE, QString("Fusion"));
#endif
        QStringList keys(QStyleFactory::keys());
        if (keys.contains(var.toString()) == true)
            s_saneStyle = QStyleFactory::create(var.toString());
        else
            s_saneStyle = QApplication::style();
    }

    return s_saneStyle;
}
Exemplo n.º 15
0
void
MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const uint32_t aPluginId)
{
  RefPtr<DetailedPromise> promise(RetrievePromise(aId));
  if (!promise) {
    return;
  }
  mNodeId = aNodeId;
  RefPtr<MediaKeys> keys(this);
  EME_LOG("MediaKeys[%p]::OnCDMCreated() resolve promise id=%d", this, aId);
  promise->MaybeResolve(keys);
  if (mCreatePromiseId == aId) {
    Release();
  }

  MediaKeySystemAccess::NotifyObservers(mParent,
                                        mKeySystem,
                                        MediaKeySystemStatus::Cdm_created);
}
Exemplo n.º 16
0
void query_ids()
{
	mapping mud_list;
	mixed *muds;
	object me;
	int i;
 if(find_object(DNS_MASTER))
 {
  mud_list=(mapping)DNS_MASTER->query_muds();
  muds = keys(mud_list);
  for(i=0;i<sizeof(muds);i++)
        if(( muds[i] != lower_case(INTERMUD_MUD_NAME)))
        {
                RWHO_Q->send_rwho_q(muds[i],this_object(),1);
                RWHO_Q->send_rwho_q(muds[i],this_object(),0);
        }
 }
 call_out("query_remotes",1*60);
}
Exemplo n.º 17
0
QAxFactory *qAxFactory()
{
    if (!qax_factory) {
        bool hadQApp = qApp != 0;
        qax_factory = qax_instantiate();
        // QAxFactory created a QApplication
        if (!hadQApp && qApp)
            qax_ownQApp = true;

        // register all types with metatype system as pointers
        QStringList keys(qax_factory->featureList());
        for (int i = 0; i < keys.count(); ++i) {
            QByteArray pointerType = keys.at(i).toLatin1() + '*';
            if (!QMetaType::type(pointerType.constData()))
                qRegisterMetaType<void *>(pointerType);
        }
    }
    return qax_factory;
}
Exemplo n.º 18
0
int main() {
    std::vector<int> keys ( 1000 );
    std::vector<int> items( keys.size() );
    for( unsigned i = 0; i < keys.size(); ++i ) {
        keys [ i ] = rand() % ( keys.size() / 2 );
        items[ i ] = keys [ i ];
    }

    HashMap<int,int,16> hash_map;

    for( unsigned i = 0; i < keys.size(); ++i )
        hash_map.add( keys[ i ], &items[ i ] );

    for( unsigned i = 0; i < keys.size(); ++i )
        if ( int *it = hash_map.find( keys[ i ] )  )
            ASSERT( keys[ i ] == *it, "..." );
        else
            ERROR( "not found" );
}
Exemplo n.º 19
0
int cmd_groups(string str) {
      string label;

     mapping groups=master()->query_groups();
      string *lists=sort_array(keys(groups),-1);
      string *club;
         int countera=sizeof(lists);

    if(!str) {

       for(countera;countera>0;countera--) {
           club=({});
          label=lists[countera-1];
           club=sort_array((groups[label]),1);

         write("%^GREEN%^%^BOLD%^Group name :: %^RED%^%^BOLD%^"+label+"%^CYAN%^%^BOLD%^");
         write(format_page(club,4));
                   } // End for loop
         return 1; } // end listing of ALL groups if no str is entered
Exemplo n.º 20
0
/* ************************************************************************* */
boost::shared_ptr<GaussianFactor>
LinearizedHessianFactor::linearize(const Values& c) const {

  // Construct an error vector in key-order from the Values
  Vector dx = Vector::Zero(dim());
  size_t index = 0;
  for(unsigned int i = 0; i < this->size(); ++i){
    Key key = this->keys()[i];
    const Value& newPt = c.at(key);
    const Value& linPt = lin_points_.at(key);
    dx.segment(index, linPt.dim()) = linPt.localCoordinates_(newPt);
    index += linPt.dim();
  }

  // f2 = f1 - 2*dx'*g1 + dx'*G1*dx
  //newInfo(this->size(), this->size())(0,0) += -2*dx.dot(linearTerm()) + dx.transpose() * squaredTerm().selfadjointView<Eigen::Upper>() * dx;
  double f = constantTerm() - 2*dx.dot(linearTerm()) + dx.transpose() * squaredTerm() * dx;

  // g2 = g1 - G1*dx
  //newInfo.rangeColumn(0, this->size(), this->size(), 0) -= squaredTerm().selfadjointView<Eigen::Upper>() * dx;
  Vector g = linearTerm() - squaredTerm() * dx;
  std::vector<Vector> gs;
  std::size_t offset = 0;
  for(DenseIndex i = 0; i < info_.nBlocks()-1; ++i) {
    const std::size_t dim = info_.getDim(i);
    gs.push_back(g.segment(offset, dim));
    offset += dim;
  }

  // G2 = G1
  // Do Nothing
  std::vector<Matrix> Gs;
  for(DenseIndex i = 0; i < info_.nBlocks()-1; ++i) {
    Gs.push_back(info_.diagonalBlock(i));
    for(DenseIndex j = i + 1; j < info_.nBlocks()-1; ++j) {
      Gs.push_back(info_.aboveDiagonalBlock(i, j));
    }
  }

  // Create a Hessian Factor from the modified info matrix
  //return boost::shared_ptr<GaussianFactor>(new HessianFactor(js, newInfo));
  return boost::shared_ptr<GaussianFactor>(new HessianFactor(keys(), Gs, gs, f));
}
// get key from users input, put into primary or alternate label for display to user
void BtShortcutsDialog::keyReleaseEvent(QKeyEvent* event) {
    int key = event->key();
    if ( (key == Qt::Key_Shift) || (key == Qt::Key_Control) || (key == Qt::Key_Meta) || (key == Qt::Key_Alt) )
        return;

    QKeySequence keys(key);
    QString keyStr = keys.toString();
    if ( (event->modifiers() & Qt::AltModifier) == Qt::AltModifier)
        keyStr = "Alt+" + keyStr;
    if ( (event->modifiers() & Qt::ShiftModifier) == Qt::ShiftModifier)
        keyStr = "Shift+" + keyStr;
    if ( (event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier)
        keyStr = "Ctrl+" + keyStr;

    QKeySequence completeKeys(keyStr);
    QString completeStr = completeKeys.toString();

    keyChangeRequest(completeStr);
}
Exemplo n.º 22
0
bool EntryAttributes::areCustomKeysDifferent(const EntryAttributes* other)
{
    // check if they are equal ignoring the order of the keys
    if (keys().toSet() != other->keys().toSet()) {
        return true;
    }

    Q_FOREACH (const QString& key, keys()) {
        if (isDefaultAttribute(key)) {
            continue;
        }

        if (isProtected(key) != other->isProtected(key) || value(key) != other->value(key)) {
            return true;
        }
    }

    return false;
}
Exemplo n.º 23
0
int main(object me, string str)  
{ 
        object ob;  
        string file;  
        mapping ol; 
        string item; 
        string *items; 
        string nitem; 
        string msg; 

        if (! SECURITY_D->valid_grant(me, "(admin)")) 
                return 0;
	
        if (! str)   
                ob = me;   
        else   
        {   
                ob = present(str, environment(me));   
                if (! ob) ob = find_player(str);   
                if (! ob) ob = find_living(str);   
                if (! ob) return notify_fail("你要查看谁的召唤列表?\n");   
        }  
        
        // 获取可召唤物品列表 
        
        if (! mapp(ol = ob->query("can_summon")) || sizeof(ol) < 1) 
                return notify_fail("你现在还没有可以召唤的物品。\n"); 
 
        msg = ob->query("name") + "(" + ob->query("id") + ")可以召唤的物品有:\n\n"; 
        items = keys(ol); 
        foreach (item in items) 
        { 
                file = (string) ol[item]; 
                if (file_size(file + ".c") < 0 && file_size(file) < 0) 
                        nitem = HIR"<不存在的武器ID,请与巫师联系>"NOR; 
                else 
                { 
                        call_other(file, "???"); 
                        if (objectp(ob = find_object(file))) 
                                nitem = ob->name(); 
                } 
                msg += sprintf(WHT "%-14s  %-14s\n", item, nitem); 
        } 
Exemplo n.º 24
0
void
MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId)
{
  nsRefPtr<Promise> promise(RetrievePromise(aId));
  if (!promise) {
    NS_WARNING("MediaKeys tried to resolve a non-existent promise");
    return;
  }
  mNodeId = aNodeId;
  nsRefPtr<MediaKeys> keys(this);
  promise->MaybeResolve(keys);
  if (mCreatePromiseId == aId) {
    Release();
  }

  MediaKeySystemAccess::NotifyObservers(mParent,
                                        mKeySystem,
                                        MediaKeySystemStatus::Cdm_created);
}
Exemplo n.º 25
0
QStringList WzConfig::childKeys() const
{
	QStringList ret(m_settings.childKeys());
	int i;
	QStringList keys(m_overrides.keys());
	QString group = slashedGroup();
	for (i = 0; i < keys.length(); i++)
	{
		if (!keys[i].startsWith(group)) 
			continue;
		keys[i].remove(0, group.length());
		if (keys[i].indexOf("/") > -1)
			continue;
		if (ret.contains(keys[i]))
			continue;
		ret.append(keys[i]);
	}
	return ret;
}
Exemplo n.º 26
0
// This is the interface to the intermud channels
void send_msg(string channel, string id, string name, string msg, int emoted)
{
	string *names;
	int i;
	mapping muds;
	mapping svcs;
	mapping minfo;




	if( !this_player()		// Prevent from being called by ourself.
	||	!ACCESS_CHECK(previous_object())) return;
#ifdef DEBUG
	set("channel_id", "网际巫师频道精灵");
	CHANNEL_D->do_channel(this_object(), "sys", "prepare to send gwizmsg");
#endif
	muds = (mapping)DNS_MASTER->query_muds();
	svcs = (mapping)DNS_MASTER->query_svc();
	msg = replace_string(msg, "|", "");
	msg = replace_string(msg, "@@@", "");
	// use keys(svcs) because none of the muds not in svcs can possibley
	// receive the message
	names = keys(svcs);
	i = sizeof(names);
	while(i--)
		if (names[i] != mud_nname()) {
			minfo = muds[names[i]];
			if(!mapp(minfo) || !mapp(svcs[names[i]])
			|| !(svcs[names[i]]["gwizmsg"] & SVC_UDP))
				continue;
			DNS_MASTER->send_udp(minfo["HOSTADDRESS"], minfo["PORTUDP"],
				"@@@" + DNS_GWIZMSG +
				"||NAME:" + Mud_name() +
				"||PORTUDP:" + udp_port() +
				"||WIZNAME:" + capitalize(id) +
				"||CNAME:" + name +
				"||GWIZ:" + msg +
				"||CHANNEL:" + channel +
				(emoted?"||EMOTE:1":"") + "@@@\n");
		}
}
Exemplo n.º 27
0
static TRI_json_t* GetMergedKeyArray (TRI_json_t const* lhs,
                                      TRI_json_t const* rhs) {
    TRI_ASSERT(lhs->_type == TRI_JSON_OBJECT);
    TRI_ASSERT(rhs->_type == TRI_JSON_OBJECT);

    size_t n = TRI_LengthVector(&lhs->_value._objects) + TRI_LengthVector(&rhs->_value._objects);

    std::unique_ptr<TRI_json_t> keys(TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE, n));

    if (keys == nullptr) {
        return nullptr;
    }

    if (TRI_CapacityVector(&(keys.get()->_value._objects)) < n) {
        return nullptr;
    }

    n = TRI_LengthVector(&lhs->_value._objects);

    for (size_t i = 0 ; i < n; i += 2) {
        auto key = static_cast<TRI_json_t const*>(TRI_AtVector(&lhs->_value._objects, i));

        TRI_ASSERT(TRI_IsStringJson(key));
        TRI_PushBackArrayJson(TRI_UNKNOWN_MEM_ZONE, keys.get(), key);
    }


    n = TRI_LengthVector(&rhs->_value._objects);

    for (size_t i = 0 ; i < n; i += 2) {
        auto key = static_cast<TRI_json_t const*>(TRI_AtVector(&rhs->_value._objects, i));

        TRI_ASSERT(TRI_IsStringJson(key));
        TRI_PushBackArrayJson(TRI_UNKNOWN_MEM_ZONE, keys.get(), key);
    }

    // sort the key array in place
    TRI_SortArrayJson(keys.get());

    // array is now sorted
    return TRI_UniquifyArrayJson(keys.get());
}
Exemplo n.º 28
0
void Session::Request::onAccountPageResult() {
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
    if (reply->error()) {
        qDebug() << "Network error in " << __FUNCTION__ << ": " << reply->errorString();
    }
    else {
        // Regexp for getting last visited, guild, etc
        // <strong>(?<attr>.+?):<\/strong><br\/>\s+?(<a href=\"(?<url>.+?)\">(?<content1>.+?)<\/a>|\s+(?<content2>[A-Za-z0-9 ]+?)\s+<\/p>)


        const QByteArray data = reply->readAll();
        const QString avatar = getAccountAvatar(data);
        const QString name = getAccountName(data);
        const auto badges = getAccountBadges(data);
        const int messages = getAccountMessagesUnread(data);

        // Store the account name
        _accountName = name;

        QJsonObject object;
        object.insert("name", name);
        object.insert("avatar_url", avatar);
        object.insert("messages", messages);
        object.insert("badges", QJsonArray::fromStringList(badges.keys()));
        QJsonDocument temp(object);
        emit profileData(temp.toJson());

        // Request Avatar
        if (!avatar.isEmpty()) {
            if (!_avatars.contains(avatar))
                _avatars.append(avatar);
            fetchImage(avatar);
        }
        // Request Badges
        for (const QString &key : badges.uniqueKeys()){
            const QString url = badges.value(key);
            if (url.isEmpty()) continue;
            fetchAccountBadge(key, url);
        }
    }
    reply->deleteLater();
}
Exemplo n.º 29
0
GlobalKey::GlobalKey(CommandDef *cmd)
{
    m_cmd = *cmd;
#if COMPAT_QT_VERSION >= 0x030000
    QKeySequence keys(cmd->accel);
    if (keys != QKeySequence(0)){
        string shortName = "sim_";
        shortName += number(cmd->id);
        accel = new KGlobalAccel(this);
        accel->insert(shortName.c_str(),
                      i18n(cmd->text), i18n(cmd->text),
                      keys, keys, this, SLOT(execute()));
        accel->updateConnections();
    }
#else
accel = new KGlobalAccel(this);
accel->insertItem(i18n(cmd->text), i18n(cmd->text), cmd->accel);
accel->connectItem(cmd->accel, this, SLOT(execute()));
#endif
}
Exemplo n.º 30
0
int update_condition(object me, int duration)
{
   	mapping exits;
    	string *dirs;
    	
	duration--;
	if( duration < 0 )	return 0;

	me->receive_wound("sen", 60);
	me->set_temp("last_damage_from","伤心过度,郁郁而死。\n");
	
   	if(mapp(exits = environment(me)->query("exits"))) {
    		tell_object(me, WHT"你心中忽然涌起莫名伤感,只觉悲苦凄凉,茫然不知何往。\n"NOR);
    		message("vision", me->name() + "面容凄苦,失神一般漫无目的地乱走。\n",	environment(me), me);
	    	dirs = keys(exits);
    		me->ccommand("go " + dirs[random(sizeof(dirs))]);
	}
	me->apply_condition("libie", duration);
	return 1;
}