static gboolean drive_is_cd_device (GDrive *gdrive) { BraseroMediumMonitor *monitor; BraseroDrive *drive; gchar *device; device = g_drive_get_identifier (gdrive, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); if (!device) return FALSE; DEBUG_PRINT ("Got device: %s\n", device); /* FIXME: since we call the monitor, the library should be initialized. * To avoid all the initializing we'll be able to use the new GIO API * (#594649 - Have a way to detect optical drives) */ ensure_initialized(); monitor = brasero_medium_monitor_get_default (); drive = brasero_medium_monitor_get_drive (monitor, device); g_object_unref (monitor); g_free (device); if (drive == NULL) return FALSE; g_object_unref (drive); return TRUE; }
static void copy_disc_activate_cb (NautilusMenuItem *item, gpointer user_data) { char *device_path; BraseroMediumMonitor *monitor; BraseroTrackDisc *track; BraseroDrive *drive; ensure_initialized(); device_path = g_object_get_data (G_OBJECT (item), "drive_device_path"); monitor = brasero_medium_monitor_get_default (); drive = brasero_medium_monitor_get_drive (monitor, device_path); g_object_unref (monitor); track = brasero_track_disc_new (); brasero_track_disc_set_drive (track, drive); g_object_unref (drive); launch_brasero_on_window_track (BRASERO_TRACK (track), _("Copy Disc"), NULL, GTK_WINDOW (user_data)); g_object_unref (track); }
PVideoFrame SafeNewVideoFrame(IScriptEnvironment* env, const VideoInfo& vi, int align) { ensure_initialized(); { CSLockAcquire lock(*_lock); PVideoFrame frame = env->NewVideoFrame(vi, align); assert(frame->IsWritable()); return frame; } }
bool SafeMakeWritable(IScriptEnvironment* env, PVideoFrame* pvf) { ensure_initialized(); { CSLockAcquire lock(*_lock); bool result = env->MakeWritable(pvf); assert(pvf->operator->()->IsWritable()); return result; } }
Input::KeyButton keyButtonFromStrings(std::vector<String>& parts) { ensure_initialized(); assert(!parts.empty()); const String& part = *parts.begin(); Input::KeyButton result = 0; if (StringsToScancodes.find(part) != StringsToScancodes.end()) { result = StringsToScancodes[part]; parts.erase(parts.begin()); } return result; }
static void check_disc_activate_cb (NautilusMenuItem *item, gpointer user_data) { BraseroSumDialog *dialog; ensure_initialized (); dialog = brasero_sum_dialog_new (); tool_dialog_run (BRASERO_TOOL_DIALOG (dialog), GTK_WINDOW (user_data), item); }
int closedir (DIR *dirp) { int (*real_closedir)(DIR *dirp) = dlsym (RTLD_NEXT, "closedir"); ensure_initialized (); g_mutex_lock (&direntcache_lock); g_hash_table_remove (direntcache, dirp); g_mutex_unlock (&direntcache_lock); return real_closedir (dirp); }
void seekdir (DIR *dirp, long loc) { void (*real_seekdir)(DIR *dirp, long loc) = dlsym (RTLD_NEXT, "seekdir"); ensure_initialized (); /* For now, crash if seekdir is called when we have cached entries. * If some app wants to use this and seekdir() we can implement it. */ assert_no_cached_entries (dirp); real_seekdir (dirp, loc); }
void Journal::logv(enum level lv, char const* format, va_list ap) { ensure_initialized(); if (lv < level_) return; char buf[1024]; std::vsnprintf(buf, sizeof(buf), format, ap); std::fprintf(stderr, "%s: %-8s ", name_.c_str(), stringize_error_level(lv)); std::fwrite(buf, sizeof(char), std::strlen(buf), stderr); std::fputc('\n', stderr); }
void rewinddir (DIR *dirp) { void (*real_rewinddir)(DIR *dirp) = dlsym (RTLD_NEXT, "rewinddir"); ensure_initialized (); /* Blow away the cache */ g_mutex_lock (&direntcache_lock); g_hash_table_remove (direntcache, dirp); g_mutex_unlock (&direntcache_lock); real_rewinddir (dirp); }
int readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) { int (*real_readdir_r)(DIR *dirp, struct dirent *entry, struct dirent **result) = dlsym (RTLD_NEXT, READDIR_R); ensure_initialized (); /* For now, assert that no one is mixing readdir_r() with readdir(). * It'd be broken to do so, and very few programs use readdir_r() * anyways. */ assert_no_cached_entries (dirp); return real_readdir_r (dirp, entry, result); }
static void write_iso_activate_cb (NautilusMenuItem *item, gpointer user_data) { BraseroTrackImageCfg *track; NautilusFileInfo *file_info; char *uri; ensure_initialized(); file_info = g_object_get_data (G_OBJECT (item), "file_info"); uri = nautilus_file_info_get_uri (file_info); track = brasero_track_image_cfg_new (); brasero_track_image_cfg_set_source (track, uri); g_signal_connect (track, "changed", G_CALLBACK (brasero_nautilus_track_changed_cb), user_data); }
static void write_activate (NautilusDiscBurn *burn, GtkWindow *toplevel) { BraseroTrackDataCfg *track; BraseroSessionCfg *session; if (nautilus_disc_burn_is_empty (toplevel)) return; ensure_initialized (); track = brasero_track_data_cfg_new (); brasero_track_data_cfg_add (track, BURN_URI, NULL); if (burn->priv->icon) brasero_track_data_cfg_set_icon (BRASERO_TRACK_DATA_CFG (track), burn->priv->icon, NULL); session = brasero_session_cfg_new (); brasero_burn_session_add_track (BRASERO_BURN_SESSION (session), BRASERO_TRACK (track), NULL); g_object_unref (track); if (burn->priv->title) brasero_burn_session_set_label (BRASERO_BURN_SESSION (session), burn->priv->title); /* NOTE: set the disc we're handling */ launch_brasero_on_window_session (session, _("CD/DVD Creator"), NULL, toplevel); /* cleanup */ g_object_unref (session); }
void Journal::level(enum Journal::level level) { ensure_initialized(); level_ = level; }
T *operator->() const { ensure_initialized(); return m_ptr; }
struct dirent * readdir (DIR *dirp) { struct dirent *(*real_readdir)(DIR *dirp) = dlsym (RTLD_NEXT, READDIR); struct dirent *ret; gboolean cache_another = TRUE; ensure_initialized (); /* The core idea here is that each time through the loop, we read a * directory entry. If there is one, we choose whether to cache it * or to return it. Because multiple entries can be cached, * ordering is randomized. Statistically, the order will still be * *weighted* towards the ordering returned from the * kernel/filesystem, but the goal here is just to provide some * randomness in order to trigger bugs, not to be perfectly random. */ while (cache_another) { DirEntries *de; errno = 0; ret = real_readdir (dirp); if (ret == NULL && errno != 0) goto out; g_mutex_lock (&direntcache_lock); de = g_hash_table_lookup (direntcache, dirp); if (ret) { if (g_random_boolean ()) { struct dirent *copy; if (!de) { de = dir_entries_new (); g_hash_table_insert (direntcache, dirp, de); } copy = g_memdup (ret, sizeof (struct dirent)); g_ptr_array_add (de->entries, copy); } else { cache_another = FALSE; } } else { if (de && de->offset < de->entries->len) { ret = de->entries->pdata[de->offset]; de->offset++; } cache_another = FALSE; } g_mutex_unlock (&direntcache_lock); } out: return ret; }
T *get() const { ensure_initialized(); return m_ptr; }
String keyButtonString(Input::KeyButton b) { ensure_initialized(); if (ScancodesToStrings.find(b) != ScancodesToStrings.end()) return ScancodesToStrings[b]; return ""; }
void Journal::flush() { ensure_initialized(); std::fflush(stderr); }