status_t icon_for_type(const BMimeType& type, BBitmap& bitmap, icon_size size, icon_source* _source) { icon_source source = kNoIcon; if (type.GetIcon(&bitmap, size) == B_OK) source = kOwnIcon; if (source == kNoIcon) { // check for icon from preferred app char preferred[B_MIME_TYPE_LENGTH]; if (type.GetPreferredApp(preferred) == B_OK) { BMimeType preferredApp(preferred); if (preferredApp.GetIconForType(type.Type(), &bitmap, size) == B_OK) source = kApplicationIcon; } } if (source == kNoIcon) { // check super type for an icon BMimeType superType; if (type.GetSupertype(&superType) == B_OK) { if (superType.GetIcon(&bitmap, size) == B_OK) source = kSupertypeIcon; else { // check the super type's preferred app char preferred[B_MIME_TYPE_LENGTH]; if (superType.GetPreferredApp(preferred) == B_OK) { BMimeType preferredApp(preferred); if (preferredApp.GetIconForType(superType.Type(), &bitmap, size) == B_OK) source = kSupertypeIcon; } } } } if (_source) *_source = source; return source != kNoIcon ? B_OK : B_ERROR; }
bool KIMProxy::startPreferredApp() { TQString preferences = TQString("[X-DCOP-ServiceName] = '%1'").arg( preferredApp() ); // start/find an instance of DCOP/InstantMessenger TQString error; TQCString dcopService; // Get a preferred IM client. // The app will notify itself to us using registeredToDCOP, so we don't need to record a stub for it here // FIXME: error in preferences, see debug output preferences = TQString::null; int result = KDCOPServiceStarter::self()->findServiceFor( IM_SERVICE_TYPE, TQString::null, preferences, &error, &dcopService ); kdDebug( 790 ) << k_funcinfo << "error was: " << error << ", dcopService: " << dcopService << endl; return ( result == 0 ); }
KIMIface_stub * KIMProxy::stubForProtocol( const TQString &protocol) { KIMIface_stub * app; // see if the preferred client supports this protocol TQString preferred = preferredApp(); if ( ( app = m_im_client_stubs.find( preferred ) ) ) { if ( app->protocols().grep( protocol ).count() > 0 ) return app; } // preferred doesn't do this protocol, try the first of the others that says it does TQDictIterator<KIMIface_stub> it( m_im_client_stubs ); for ( ; it.current(); ++it ) { if ( it.current()->protocols().grep( protocol ).count() > 0 ) return it.current(); } return 0L; }