Mounting samba share in C++ using Giomm



Update: the uri in source code isn't correct, but I still get those error messages. The valid source code is:

#include <gtkmm.h>

#include <iostream>

Glib::RefPtr<Gio::File> file;
Glib::RefPtr<Glib::MainLoop> main_loop;

void on_async_ready(Glib::RefPtr<Gio::AsyncResult>& result)
{
    file->mount_enclosing_volume_finish(result);

    main_loop->quit();
}

int main()
{
    Gio::init();
    Glib::init();

    main_loop = Glib::MainLoop::create(false);

    file = Gio::File::create_for_commandline_arg("smb://192.168.1.3/Memory core");
    Glib::RefPtr<Gio::MountOperation> mount_operation = Gio::MountOperation::create();
    mount_operation->set_domain("domain");
    mount_operation->set_username("user");
    mount_operation->set_password("password");

    try
    {
        file->mount_enclosing_volume(mount_operation, &on_async_ready);
    }
    catch(const Glib::Error& ex)
    {
        std::cerr << ex.what() << std::endl;
    }

    main_loop->run();

    return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]