Esempio n. 1
0
int xRead(sqlite3_file* p_file, void* buff, int iAmt, sqlite3_int64 iOfst)
{
	sqlite3_file_fb2k * p_fb2kfile = static_cast<sqlite3_file_fb2k*>(p_file);
	if (p_fb2kfile->m_file)
	{
		try
		{
			t_size read = 0;
			try {
				if (iOfst < p_fb2kfile->m_file->get_ptr()->get_size_ex(abort_callback_dummy()))
				{
				p_fb2kfile->m_file->get_ptr()->seek(iOfst, abort_callback_dummy());
				read = p_fb2kfile->m_file->get_ptr()->read(buff, iAmt, abort_callback_dummy());
				}
			} catch (exception_io_seek_out_of_range const &) {};
			
			if (iAmt > 0 && read < (unsigned)iAmt)
			{
				memset((t_uint8*)buff + read, 0, iAmt-read);
				return SQLITE_IOERR_SHORT_READ;
			}
			return SQLITE_OK;
		} catch (pfc::exception const & ex) 
		{
			console::formatter() << "iPod manager: xRead error: " << ex.what();
		}
	}
	return SQLITE_IOERR_READ;
}
Esempio n. 2
0
int xAccess(sqlite3_vfs*, const char *zName, int flags, int *pResOut)
{
	*pResOut = FALSE;
	try {
		if (flags == SQLITE_ACCESS_READWRITE)
		{
			if (filesystem::g_exists_writeable(zName, abort_callback_dummy()))
			{
				*pResOut = TRUE;
			}
		}
		else// if (flags == SQLITE_ACCESS_READWRITE)
		{
			if (filesystem::g_exists(zName, abort_callback_dummy()))
			{
				*pResOut = TRUE;
			}
		}
	}
#if 0
	catch (exception_io_denied const &) 
	{
		if (flags == SQLITE_ACCESS_EXISTS)
			*pResOut = TRUE;
		else
			*pResOut = FALSE;
	}
#endif
	catch (pfc::exception const & ex) 
	{
		console::formatter() << "iPod manager: xAccess error: " << ex.what();
		return SQLITE_IOERR;
	}
	return SQLITE_OK;
}
Esempio n. 3
0
		void load_database_t::save_cache(HWND wnd, ipod_device_ptr_ref_t p_ipod, threaded_process_v2_t & p_status, abort_callback & p_abort) const
		{
			//pfc::array_staticsize_t<threaded_process_v2_t::detail_entry> progress_details(1);
			//progress_details[0].m_label = "Database:";
			//progress_details[0].m_value = "Metadata cache";
			p_status.update_text("Saving metadata cache");

			pfc::string8 base;
			p_ipod->get_root_path(base);

			pfc::string8 path = base; path << "metadata_cache.fpl";
			try
			{
				playlist_loader::g_save_playlist(path, m_handles, abort_callback_dummy());
			}
			catch (const pfc::exception & ex)
			{
				try { filesystem::g_remove(path, abort_callback_dummy()); }
				catch (pfc::exception const &) {};
				console::formatter() << "iPod manager: Error saving metadata_cache.fpl to iPod: " << ex.what();
				//throw;
			}
			p_status.checkpoint();
		}
Esempio n. 4
0
int xFileSize(sqlite3_file* p_file, sqlite3_int64 *pSize)
{
	sqlite3_file_fb2k * p_fb2kfile = static_cast<sqlite3_file_fb2k*>(p_file);
	if (p_fb2kfile->m_file)
	{
		try
		{
			*pSize = p_fb2kfile->m_file->get_ptr()->get_size_ex(abort_callback_dummy());
			return SQLITE_OK;
		} 
		catch (pfc::exception const & ex) 
		{
			console::formatter() << "iPod manager: xFileSize error: " << ex.what();
		}
	}
	return SQLITE_IOERR_FSTAT;
}
Esempio n. 5
0
int xDelete(sqlite3_vfs*, const char *zName, int syncDir)
{
	try {
		filesystem::g_remove(zName, abort_callback_dummy());
	} 
	catch (exception_io_not_found const &) 
	{
		//console::formatter() << "iPod manager: xDelete error: " << ex.what();
		//return SQLITE_IOERR;
	}
	catch (pfc::exception const & ex) 
	{
		console::formatter() << "iPod manager: xDelete error: " << ex.what();
		return SQLITE_IOERR;
	}
	return SQLITE_OK;
}
Esempio n. 6
0
int xTruncate(sqlite3_file* p_file, sqlite3_int64 size)
{
	sqlite3_file_fb2k * p_fb2kfile = static_cast<sqlite3_file_fb2k*>(p_file);
	if (p_fb2kfile->m_file)
	{
		try
		{
			p_fb2kfile->m_file->get_ptr()->resize(size, abort_callback_dummy());
			//p_fb2kfile->m_file->get_ptr()->seek(size, abort_callback_dummy());
			//p_fb2kfile->m_file->get_ptr()->set_eof(abort_callback_dummy());
			return SQLITE_OK;
		} catch (pfc::exception const & ex) 
		{
			console::formatter() << "iPod manager: xTruncate error: " << ex.what();
		}
	}
	return SQLITE_IOERR_TRUNCATE;
}
Esempio n. 7
0
void filesystem::g_copy(const char * src,const char * dst,abort_callback & p_abort) {
	service_ptr_t<file> r_src,r_dst;
	t_filesize size;

	g_open(r_src,src,open_mode_read,p_abort);
	size = r_src->get_size_ex(p_abort);
	g_open(r_dst,dst,open_mode_write_new,p_abort);
	
	if (size > 0) {
		try {
			file::g_transfer_object(r_src,r_dst,size,p_abort);
		} catch(...) {
			r_dst.release();
			try {g_remove(dst,abort_callback_dummy());} catch(...) {}
			throw;
		}
	}
}
Esempio n. 8
0
void config_object::get_data_string(pfc::string_base & p_out) {
	get_data(&stream_writer_string(p_out),abort_callback_dummy());
}
Esempio n. 9
0
void config_object::set_data_raw(const void * p_data,t_size p_bytes, bool p_notify) {
	set_data(&stream_reader_memblock_ref(p_data,p_bytes),abort_callback_dummy(),p_notify);
}
Esempio n. 10
0
t_size config_object::get_data_raw_length() {
	t_size ret = 0;
	get_data(&stream_writer_get_length(ret),abort_callback_dummy());
	return ret;
}
Esempio n. 11
0
t_size config_object::get_data_raw(void * p_out,t_size p_bytes) {
	t_size ret = 0;
	get_data(&stream_writer_fixedbuffer(p_out,p_bytes,ret),abort_callback_dummy());
	return ret;
}
Esempio n. 12
0
BOOL t_config_tab3::DialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
{
	switch (msg)
	{
		case WM_INITDIALOG:
		{
			m_initialising = true;
			m_wnd_enabled = GetDlgItem(wnd, IDC_ENABLED);
			Button_SetCheck(m_wnd_enabled, settings::mobile_devices_enabled ? BST_CHECKED : BST_UNCHECKED);
			m_initialising = false;
		}
		break;
		case WM_COMMAND:
			switch (wp)
			{
				case IDC_ENABLED | (BN_CLICKED << 16) :
					settings::mobile_devices_enabled = Button_GetCheck(m_wnd_enabled) == BST_CHECKED;
					break;
#if 0
				case IDC_DIR:
				{
					string_utf8_from_window dir(wnd, IDC_PATH);
					pfc::string8 dir_can, output;
					try
					{
						filesystem::g_get_canonical_path(dir, dir_can);
						directory_callback_full_impl list(false);
						filesystem::g_list_directory(dir_can, list, abort_callback_dummy());
						t_size i, count = list.get_count();
						for (i = 0; i<count; i++)
						{
							if (list[i].m_subdir)
								output << "<dir> ";
							output << list[i].m_path;
							//output << "     " << list[i].m_stats.m_size;
							//if (list[i].m_stats.m_timestamp != filetimestamp_invalid)
							//	output << "     " << format_filetimestamp(list[i].m_stats.m_timestamp);
							output << "\r\n";
						}
					}
					catch (const pfc::exception & ex)
					{
						output << "\r\nError: " << ex.what();
					}
					uSendDlgItemMessageText(wnd, IDC_OUTPUT, WM_SETTEXT, NULL, output.get_ptr());
				}
				break;
				case IDC_STATS:
				{
					pfc::string8 output;
					try
					{
						pfc::list_t<stats_t> stats;
						g_get_stats_list(string_utf8_from_window(wnd, IDC_PATH), stats);
						t_size i, count = stats.get_count();
						for (i = 0; i<count; i++)
							output << stats[i].name << "=" << stats[i].value << "\r\n";
					}
					catch (const pfc::exception & ex)
					{
						output << "\r\nError: " << ex.what();
					}
					uSendDlgItemMessageText(wnd, IDC_OUTPUT, WM_SETTEXT, NULL, output.get_ptr());
				}
				break;
				case IDC_TEST:
				{
					//console::formatter() << pfc::format_hex(IOCTL_SCSI_PASS_THROUGH);
					mobile_device_api_t::ptr api = g_get_mobile_device_api();
					mobile_device_api_t::device_handle_t::ptr handle;
					if (api.is_valid() && api->is_initialised())
					{
						{
							insync(api->m_devices_sync);
							if (api->m_devices.get_count())
								handle = api->m_devices[0];
						}
						if (handle.is_valid())
						{
							try
							{
								pfc::string8 msg;
								CFTypeRef ref = NULL;
								msg << "\r\n1:\r\n";
								ref = api->AMDeviceCopyValue(api->m_devices[0]->m_device, api->_CFSTR("com.apple.mobile.iTunes"), NULL);
								msg << "Ref: " << pfc::format_hex((t_uint64)ref, 8) << "\r\n";
								if (ref)
								{
									g_print_CFTypeRef(api, ref, msg);
									api->CFRelease(ref);
									ref = NULL;
								}
								msg << "\r\n2:\r\n";
								ref = api->AMDeviceCopyValue(api->m_devices[0]->m_device, NULL, NULL);
								msg << "Ref: " << pfc::format_hex((t_uint64)ref, 8) << "\r\n";
								if (ref)
								{
									g_print_CFTypeRef(api, ref, msg);
									api->CFRelease(ref);
									ref = NULL;
								}
								msg << "\r\n3:\r\n";
								ref = api->AMDeviceCopyValue(api->m_devices[0]->m_device, api->_CFSTR("com.apple.mobile.battery"), NULL);
								msg << "Ref: " << pfc::format_hex((t_uint64)ref, 8) << "\r\n";
								if (ref)
								{
									g_print_CFTypeRef(api, ref, msg);
									api->CFRelease(ref);
									ref = NULL;
								}
								msg << "\r\n4:\r\n";
								ref = api->AMDeviceCopyValue(api->m_devices[0]->m_device, api->_CFSTR("com.apple.disk_usage"), NULL);
								msg << "Ref: " << pfc::format_hex((t_uint64)ref, 8) << "\r\n";
								if (ref)
								{
									g_print_CFTypeRef(api, ref, msg);
									api->CFRelease(ref);
									ref = NULL;
								}
								msg << "\r\n5:\r\n";
								ref = api->AMDeviceCopyValue(api->m_devices[0]->m_device, api->_CFSTR("com.apple.mobile.sync_data_class"), NULL);
								msg << "Ref: " << pfc::format_hex((t_uint64)ref, 8) << "\r\n";
								if (ref)
								{
									g_print_CFTypeRef(api, ref, msg);
									api->CFRelease(ref);
									ref = NULL;
								}
								msg << "\r\n6:\r\n";
								ref = api->AMDeviceCopyValue(api->m_devices[0]->m_device, NULL, api->_CFSTR("DeviceClass"));
								msg << "Ref: " << pfc::format_hex((t_uint64)ref, 8) << "\r\n";
								if (ref)
								{
									g_print_CFTypeRef(api, ref, msg);
									api->CFRelease(ref);
									ref = NULL;
								}
								msg << "\r\n7:\r\n";
								ref = api->AMDeviceCopyValue(api->m_devices[0]->m_device, NULL, api->_CFSTR("DeviceName"));
								msg << "Ref: " << pfc::format_hex((t_uint64)ref, 8) << "\r\n";
								if (ref)
								{
									g_print_CFTypeRef(api, ref, msg);
									api->CFRelease(ref);
									ref = NULL;
								}
								popup_message::g_show(msg, "Test Results");
								//NULL
								//com.apple.mobile.iTunes
								//com.apple.mobile.battery
								//com.apple.disk_usage
								//com.apple.mobile.sync_data_class
								//DeviceClass
								//DeviceName
							}
							catch (const pfc::exception & ex)
							{
								popup_message::g_show(ex.what(), "Test Error");
							}
						}
					}
				}
				break;
#endif
			}
			break;
		case WM_DESTROY:
			m_wnd_enabled = NULL;
			break;
	}
	return FALSE;
}
Esempio n. 13
0
int xOpen(sqlite3_vfs*, const char *zName, sqlite3_file* p_file,int flags, int *pOutFlags)
{
	sqlite3_file_fb2k * p_fb2kfile = static_cast<sqlite3_file_fb2k*>(p_file);
	p_fb2kfile->pMethods = &xIoMethod;
	p_fb2kfile->m_file = NULL;
	filesystem::t_open_mode fb2kMode = filesystem::open_mode_read;
	pfc::string8 temp;
	if (!zName)
	{
		uGetTempPath(temp);
		temp;// << "\\";
		FILETIME ft;
		GetSystemTimeAsFileTime(&ft);
		srand(ft.dwLowDateTime);
		temp << (unsigned) ft.dwHighDateTime << (unsigned) ft.dwLowDateTime << rand() << ".dop.temp";
		zName = temp.get_ptr();
	}
	if (flags & SQLITE_OPEN_READONLY)
	{
		fb2kMode = filesystem::open_mode_read;
		if (pOutFlags)
			*pOutFlags = SQLITE_OPEN_READONLY;
	}
	else if (flags & SQLITE_OPEN_READWRITE)
	{
		fb2kMode = filesystem::open_mode_write_existing;
		if (pOutFlags)
			*pOutFlags = SQLITE_OPEN_READWRITE;
	}
	else if ( (flags & (SQLITE_OPEN_CREATE|SQLITE_OPEN_EXCLUSIVE)) == (SQLITE_OPEN_CREATE|SQLITE_OPEN_EXCLUSIVE) )
	{
		fb2kMode = filesystem::open_mode_write_new;
		*pOutFlags = SQLITE_OPEN_CREATE|SQLITE_OPEN_EXCLUSIVE;
	}
	else if (flags & (SQLITE_OPEN_CREATE))
	{
		fb2kMode = filesystem::open_mode_write_existing;
		*pOutFlags = SQLITE_OPEN_CREATE;
	}
	else return SQLITE_NOLFS;

	try
	{
		file::ptr ptr;
		try {
		filesystem::g_open(ptr, zName, fb2kMode, abort_callback_dummy());
		}
		catch (exception_io_not_found const &)
		{
			if (flags & (SQLITE_OPEN_CREATE))
			{
				filesystem::g_open_write_new(ptr, zName, abort_callback_dummy());
				if (pOutFlags)
					*pOutFlags |= SQLITE_OPEN_CREATE;
			}
			else throw;			
		}

		p_fb2kfile->m_file = new file::ptr(ptr.get_ptr());
	}
	catch (const exception_io & ex) 
	{
		console::formatter() << "iPod manager: xOpen error: " << ex.what();
		return SQLITE_IOERR;
	}

	return SQLITE_OK;
}
Esempio n. 14
0
void layout_window::g_get_default_presets(pfc::list_t<cfg_layout_t::preset> & p_out)
{
	{
		uie::window_ptr wnd, wnd2, wnd3;
		service_ptr_t<uie::splitter_window> splitter, splitter2, splitter3;
		if (uie::window::create_by_guid(columns_ui::panels::guid_horizontal_splitter, wnd) && uie::window::create_by_guid(columns_ui::panels::guid_vertical_splitter, wnd2))
		{
			if (wnd->service_query_t(splitter) && wnd2->service_query_t(splitter2))
			{
				uie::splitter_item_simple_t item, item2;
				item.set_panel_guid(columns_ui::panels::guid_playlist_switcher);
				item2.set_panel_guid(columns_ui::panels::guid_vertical_splitter);
				bool val = true;
				splitter2->add_panel(&item);
				stream_writer_memblock conf1;
				splitter2->get_config(&conf1, abort_callback_impl());
				item2.set_panel_config(&stream_reader_memblock_ref(conf1.m_data.get_ptr(), conf1.m_data.get_size()), conf1.m_data.get_size());

				t_size index = splitter->add_panel(&item2);
				splitter->set_config_item(index, uie::splitter_window::bool_locked, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());
				val = false;
				splitter->set_config_item(index, uie::splitter_window::bool_show_caption, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());
				t_uint32 sz = 175;
				splitter->set_config_item(index, uie::splitter_window::uint32_size, &stream_reader_memblock_ref(&sz, sizeof(t_uint32)), abort_callback_impl());

				item.set_panel_guid(columns_ui::panels::guid_playlist_view_v2);
				t_size index_playlist = splitter->add_panel(&item);
				splitter->set_config_item(index_playlist, uie::splitter_window::bool_show_caption, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());

				cfg_layout_t::preset preset_default;
				preset_default.m_name = "NG Playlist + Playlist Switcher";
				preset_default.m_guid = columns_ui::panels::guid_horizontal_splitter;
				stream_writer_memblock_ref conf(preset_default.m_val, true);
				splitter->get_config(&conf, abort_callback_impl());

				p_out.add_item(preset_default);
			}
		}
	}
	{
		uie::window_ptr wnd, wnd2, wnd3, wnd_filter_splitter;
		service_ptr_t<uie::splitter_window> splitter, splitter2, splitter3, splitter_filter;
		if (uie::window::create_by_guid(columns_ui::panels::guid_horizontal_splitter, wnd) && uie::window::create_by_guid(columns_ui::panels::guid_vertical_splitter, wnd2) && uie::window::create_by_guid(columns_ui::panels::guid_vertical_splitter, wnd3)
			&& uie::window::create_by_guid(columns_ui::panels::guid_horizontal_splitter, wnd_filter_splitter))
		{
			if (wnd->service_query_t(splitter) && wnd2->service_query_t(splitter2) && wnd3->service_query_t(splitter3)
				&& wnd_filter_splitter->service_query_t(splitter_filter))
			{
				uie::splitter_item_simple_t item, item2, item3, item_filter, item_filter_splitter, item_artwork;
				item.set_panel_guid(columns_ui::panels::guid_playlist_switcher);
				item2.set_panel_guid(columns_ui::panels::guid_vertical_splitter);
				item3.set_panel_guid(columns_ui::panels::guid_vertical_splitter);
				item_filter_splitter.set_panel_guid(columns_ui::panels::guid_horizontal_splitter);
				item_filter.set_panel_guid(columns_ui::panels::guid_filter);
				item_artwork.set_panel_guid(columns_ui::panels::guid_artwork_view);;
				bool val = true;
				splitter2->add_panel(&item);
				stream_writer_memblock conf1, conf2, conf3;
				splitter2->get_config(&conf1, abort_callback_impl());
				item2.set_panel_config(&stream_reader_memblock_ref(conf1.m_data.get_ptr(), conf1.m_data.get_size()), conf1.m_data.get_size());

				t_size index = splitter->add_panel(&item2);
				splitter->set_config_item(index, uie::splitter_window::bool_locked, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());
				val = false;
				splitter->set_config_item(index, uie::splitter_window::bool_show_caption, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());
				t_uint32 sz = 175;
				splitter->set_config_item(index, uie::splitter_window::uint32_size, &stream_reader_memblock_ref(&sz, sizeof(t_uint32)), abort_callback_impl());

				t_size index_filter = splitter_filter->add_panel(&item_filter);
				splitter_filter->set_config_item_t(index_filter, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				index_filter = splitter_filter->add_panel(&item_filter);
				splitter_filter->set_config_item_t(index_filter, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				index_filter = splitter_filter->add_panel(&item_filter);
				splitter_filter->set_config_item_t(index_filter, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				{
					splitter_filter->get_config(&conf3, abort_callback_impl());
					item_filter_splitter.set_panel_config(&stream_reader_memblock_ref(conf3.m_data.get_ptr(), conf3.m_data.get_size()), conf3.m_data.get_size());
					t_size indexfs = splitter3->add_panel(&item_filter_splitter);
					splitter3->set_config_item_t(indexfs, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
					bool temp = true;
					splitter3->set_config_item_t(indexfs, uie::splitter_window::bool_locked, temp, abort_callback_dummy());
					t_uint32 size = 175;
					splitter3->set_config_item_t(indexfs, uie::splitter_window::uint32_size, size, abort_callback_dummy());
				}

				item.set_panel_guid(columns_ui::panels::guid_playlist_view_v2);
				t_size index_playlist = splitter3->add_panel(&item);
				splitter3->set_config_item(index_playlist, uie::splitter_window::bool_show_caption, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());

				splitter3->get_config(&conf2, abort_callback_impl());
				item3.set_panel_config(&stream_reader_memblock_ref(conf2.m_data.get_ptr(), conf2.m_data.get_size()), conf2.m_data.get_size());

				t_size index_splitter2 = splitter->add_panel(&item3);
				splitter->set_config_item_t(index_splitter2, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());

				cfg_layout_t::preset preset_default;
				preset_default.m_name = "NG Playlist + Playlist Switcher + Filters";
				preset_default.m_guid = columns_ui::panels::guid_horizontal_splitter;
				stream_writer_memblock_ref conf(preset_default.m_val, true);
				splitter->get_config(&conf, abort_callback_impl());

				p_out.add_item(preset_default);

				index = splitter2->add_panel(&item_artwork);
				bool b_true = true;
				splitter2->set_config_item_t(index, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				splitter2->set_config_item_t(index, uie::splitter_window::bool_locked, b_true, abort_callback_dummy());
				splitter2->set_config_item_t(index, uie::splitter_window::uint32_size, sz, abort_callback_dummy());
				conf1.m_data.set_size(0);
				splitter2->get_config(&conf1, abort_callback_impl());
				item2.set_panel_config(&stream_reader_memblock_ref(conf1.m_data.get_ptr(), conf1.m_data.get_size()), conf1.m_data.get_size());
				splitter->replace_panel(0, &item2);
				splitter->set_config_item(0, uie::splitter_window::bool_locked, &stream_reader_memblock_ref(&b_true, sizeof(bool)), abort_callback_impl());
				splitter->set_config_item(0, uie::splitter_window::bool_show_caption, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());
				splitter->set_config_item(0, uie::splitter_window::uint32_size, &stream_reader_memblock_ref(&sz, sizeof(t_uint32)), abort_callback_impl());

				preset_default.m_name = "NG Playlist + Playlist Switcher + Artwork + Filters";
				preset_default.m_val.set_size(0);
				splitter->get_config(&conf, abort_callback_impl());
				t_size index_preset = p_out.add_item(preset_default);

				splitter3->remove_panel(0);
				conf2.m_data.set_size(0);
				splitter3->get_config(&conf2, abort_callback_impl());
				item3.set_panel_config(&stream_reader_memblock_ref(conf2.m_data.get_ptr(), conf2.m_data.get_size()), conf2.m_data.get_size());

				splitter->replace_panel(index_splitter2, &item3);
				splitter->set_config_item_t(index_splitter2, uie::splitter_window::bool_show_caption, false, abort_callback_dummy());
				preset_default.m_name = "NG Playlist + Playlist Switcher + Artwork";
				splitter->get_config(&stream_writer_memblock_ref(preset_default.m_val, true), abort_callback_dummy());
				p_out.insert_item(preset_default, index_preset);
			}
		}
	}
	{
		uie::window_ptr wnd, wnd2, wnd3, wnd_filter_splitter, wnd_bottom_splitter;
		service_ptr_t<uie::splitter_window> splitter, splitter2, splitter3, splitter_filter, splitter_bottom;
		if (uie::window::create_by_guid(columns_ui::panels::guid_horizontal_splitter, wnd) && uie::window::create_by_guid(columns_ui::panels::guid_vertical_splitter, wnd2) && uie::window::create_by_guid(columns_ui::panels::guid_vertical_splitter, wnd3)
			&& uie::window::create_by_guid(columns_ui::panels::guid_horizontal_splitter, wnd_filter_splitter)
			&& uie::window::create_by_guid(columns_ui::panels::guid_horizontal_splitter, wnd_bottom_splitter))
		{
			if (wnd->service_query_t(splitter) && wnd2->service_query_t(splitter2) && wnd3->service_query_t(splitter3)
				&& wnd_filter_splitter->service_query_t(splitter_filter)
				&& wnd_bottom_splitter->service_query_t(splitter_bottom))
			{
				uie::splitter_item_simple_t item, item2, item3, item_filter, item_filter_splitter, item_artwork, item_bottom_splitter, item_item_details;
				item.set_panel_guid(columns_ui::panels::guid_playlist_switcher);
				item2.set_panel_guid(columns_ui::panels::guid_vertical_splitter);
				item3.set_panel_guid(columns_ui::panels::guid_vertical_splitter);
				item_filter_splitter.set_panel_guid(columns_ui::panels::guid_horizontal_splitter);
				item_bottom_splitter.set_panel_guid(columns_ui::panels::guid_horizontal_splitter);
				item_filter.set_panel_guid(columns_ui::panels::guid_filter);
				item_artwork.set_panel_guid(columns_ui::panels::guid_artwork_view);
				item_item_details.set_panel_guid(columns_ui::panels::guid_item_details);
				bool val = true;
				splitter2->add_panel(&item);
				stream_writer_memblock conf1, conf2, conf3, conf4;
				splitter2->get_config(&conf1, abort_callback_impl());
				item2.set_panel_config(&stream_reader_memblock_ref(conf1.m_data.get_ptr(), conf1.m_data.get_size()), conf1.m_data.get_size());

				t_size index = splitter->add_panel(&item2);
				splitter->set_config_item(index, uie::splitter_window::bool_locked, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());
				val = false;
				splitter->set_config_item(index, uie::splitter_window::bool_show_caption, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());
				t_uint32 sz = 175;
				splitter->set_config_item(index, uie::splitter_window::uint32_size, &stream_reader_memblock_ref(&sz, sizeof(t_uint32)), abort_callback_impl());

				t_size index_filter = splitter_filter->add_panel(&item_filter);
				splitter_filter->set_config_item_t(index_filter, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				index_filter = splitter_filter->add_panel(&item_filter);
				splitter_filter->set_config_item_t(index_filter, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				index_filter = splitter_filter->add_panel(&item_filter);
				splitter_filter->set_config_item_t(index_filter, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				{
					splitter_filter->get_config(&conf3, abort_callback_impl());
					item_filter_splitter.set_panel_config(&stream_reader_memblock_ref(conf3.m_data.get_ptr(), conf3.m_data.get_size()), conf3.m_data.get_size());
				}

				item.set_panel_guid(columns_ui::panels::guid_playlist_view_v2);
				t_size index_playlist = splitter3->add_panel(&item);
				splitter3->set_config_item(index_playlist, uie::splitter_window::bool_show_caption, &stream_reader_memblock_ref(&val, sizeof(bool)), abort_callback_impl());

				{
					t_size index = splitter_bottom->add_panel(&item_item_details);
					splitter_bottom->set_config_item_t(index, uie::splitter_window::bool_show_caption, bool(false), abort_callback_dummy());
					index = splitter_bottom->add_panel(&item_artwork);
					splitter_bottom->set_config_item_t(index, uie::splitter_window::bool_show_caption, bool(false), abort_callback_dummy());
					splitter_bottom->set_config_item_t(index, uie::splitter_window::uint32_size, t_size(125), abort_callback_dummy());
					splitter_bottom->set_config_item_t(index, uie::splitter_window::bool_locked, bool(true), abort_callback_dummy());

					splitter_bottom->get_config(&conf4, abort_callback_impl());
					item_bottom_splitter.set_panel_config(&stream_reader_memblock_ref(conf4.m_data.get_ptr(), conf4.m_data.get_size()), conf4.m_data.get_size());
					index = splitter3->add_panel(&item_bottom_splitter);
					splitter3->set_config_item_t(index, uie::splitter_window::bool_show_caption, bool(false), abort_callback_dummy());
					splitter3->set_config_item_t(index, uie::splitter_window::bool_locked, bool(true), abort_callback_dummy());
					splitter3->set_config_item_t(index, uie::splitter_window::uint32_size, t_size(125), abort_callback_dummy());
				}

				splitter3->get_config(&conf2, abort_callback_impl());
				item3.set_panel_config(&stream_reader_memblock_ref(conf2.m_data.get_ptr(), conf2.m_data.get_size()), conf2.m_data.get_size());

				t_size index_splitter2 = splitter->add_panel(&item3);
				splitter->set_config_item_t(index_splitter2, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());

				cfg_layout_t::preset preset_default;
				preset_default.m_name = "NG Playlist + Playlist Switcher + Item Details + Artwork";
				preset_default.m_guid = columns_ui::panels::guid_horizontal_splitter;
				stream_writer_memblock_ref conf(preset_default.m_val, true);
				splitter->get_config(&conf, abort_callback_impl());

				p_out.add_item(preset_default);

				{
					t_size indexfs = 0;
					splitter3->insert_panel(0, &item_filter_splitter);
					splitter3->set_config_item_t(indexfs, uie::splitter_window::bool_show_caption, false, abort_callback_dummy());
					splitter3->set_config_item_t(indexfs, uie::splitter_window::bool_locked, true, abort_callback_dummy());
					t_uint32 size = 175;
					splitter3->set_config_item_t(indexfs, uie::splitter_window::uint32_size, size, abort_callback_dummy());
				}


				conf2.m_data.set_size(0);
				splitter3->get_config(&conf2, abort_callback_impl());
				item3.set_panel_config(&stream_reader_memblock_ref(conf2.m_data.get_ptr(), conf2.m_data.get_size()), conf2.m_data.get_size());

				//t_size index_splitter2 = 
				splitter->replace_panel(1, &item3);
				splitter->set_config_item_t(1, uie::splitter_window::bool_show_caption, false, abort_callback_dummy());

				cfg_layout_t::preset preset_default2;
				preset_default2.m_name = "NG Playlist + Playlist Switcher + Filters + Item Details + Artwork";
				preset_default2.m_guid = columns_ui::panels::guid_horizontal_splitter;
				stream_writer_memblock_ref conft(preset_default2.m_val, true);
				splitter->get_config(&conft, abort_callback_impl());

				p_out.add_item(preset_default2);
			}
		}
	}
	{
		uie::window_ptr wnd;
		service_ptr_t<uie::splitter_window> splitter;
		if (uie::window::create_by_guid(columns_ui::panels::guid_playlist_tabs, wnd))
		{
			if (wnd->service_query_t(splitter))
			{
				uie::splitter_item_simple_t item;
				item.set_panel_guid(columns_ui::panels::guid_playlist_view_v2);
				splitter->add_panel(&item);

				cfg_layout_t::preset preset_default;
				preset_default.m_name = "NG Playlist + Playlist Tabs";
				preset_default.m_guid = columns_ui::panels::guid_playlist_tabs;
				stream_writer_memblock_ref conf(preset_default.m_val, true);
				splitter->get_config(&conf, abort_callback_impl());

				//m_active = pfc_infinite;

				p_out.add_item(preset_default);
			}
		}
	}
	{
		uie::window_ptr wnd, wnd2, wnd3, wnd_filter_splitter, wnd_bottom_splitter;
		service_ptr_t<uie::splitter_window> splitter, splitter_tabs, splitter3, splitter_filter, splitter_bottom;
		if (uie::window::create_by_guid(columns_ui::panels::guid_horizontal_splitter, wnd) && uie::window::create_by_guid(columns_ui::panels::guid_playlist_tabs, wnd2) && uie::window::create_by_guid(columns_ui::panels::guid_vertical_splitter, wnd3)
			&& uie::window::create_by_guid(columns_ui::panels::guid_horizontal_splitter, wnd_filter_splitter)
			&& uie::window::create_by_guid(columns_ui::panels::guid_horizontal_splitter, wnd_bottom_splitter))
		{
			if (wnd->service_query_t(splitter) && wnd2->service_query_t(splitter_tabs) && wnd3->service_query_t(splitter3)
				&& wnd_filter_splitter->service_query_t(splitter_filter)
				&& wnd_bottom_splitter->service_query_t(splitter_bottom))
			{
				uie::splitter_item_simple_t item_tabs, item, item3, item_filter, item_filter_splitter, item_artwork, item_bottom_splitter, item_item_details;
				item_tabs.set_panel_guid(columns_ui::panels::guid_playlist_tabs);

				item3.set_panel_guid(columns_ui::panels::guid_vertical_splitter);
				item_filter_splitter.set_panel_guid(columns_ui::panels::guid_horizontal_splitter);
				item_bottom_splitter.set_panel_guid(columns_ui::panels::guid_horizontal_splitter);
				item_filter.set_panel_guid(columns_ui::panels::guid_filter);
				item_artwork.set_panel_guid(columns_ui::panels::guid_artwork_view);
				item_item_details.set_panel_guid(columns_ui::panels::guid_item_details);
				bool val = true;

				stream_writer_memblock conf1, conf2, conf3, conf4;

				val = false;
				t_uint32 sz = 175;

				t_size index_filter = splitter_filter->add_panel(&item_filter);
				splitter_filter->set_config_item_t(index_filter, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				index_filter = splitter_filter->add_panel(&item_filter);
				splitter_filter->set_config_item_t(index_filter, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				index_filter = splitter_filter->add_panel(&item_filter);
				splitter_filter->set_config_item_t(index_filter, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
				{
					splitter_filter->get_config(&conf3, abort_callback_impl());
					item_filter_splitter.set_panel_config(&stream_reader_memblock_ref(conf3.m_data.get_ptr(), conf3.m_data.get_size()), conf3.m_data.get_size());
					t_size indexfs = splitter3->add_panel(&item_filter_splitter);
					splitter3->set_config_item_t(indexfs, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());
					bool temp = true;
					splitter3->set_config_item_t(indexfs, uie::splitter_window::bool_locked, temp, abort_callback_dummy());
					t_uint32 size = 175;
					splitter3->set_config_item_t(indexfs, uie::splitter_window::uint32_size, size, abort_callback_dummy());
				}

				item.set_panel_guid(columns_ui::panels::guid_playlist_view_v2);
				t_size index_playlist = splitter_tabs->add_panel(&item);
				splitter_tabs->get_config(&conf1, abort_callback_impl());
				item_tabs.set_panel_config(&stream_reader_memblock_ref(conf1.m_data.get_ptr(), conf1.m_data.get_size()), conf1.m_data.get_size());
				t_size index_tabs = splitter3->add_panel(&item_tabs);
				splitter3->set_config_item_t(index_tabs, uie::splitter_window::bool_show_caption, false, abort_callback_impl());


				splitter3->get_config(&conf2, abort_callback_impl());
				item3.set_panel_config(&stream_reader_memblock_ref(conf2.m_data.get_ptr(), conf2.m_data.get_size()), conf2.m_data.get_size());

				t_size index_splitter2 = splitter->add_panel(&item3);
				splitter->set_config_item_t(index_splitter2, uie::splitter_window::bool_show_caption, val, abort_callback_dummy());

				cfg_layout_t::preset preset_default;
				preset_default.m_name = "NG Playlist + Playlist Tabs + Filters";
				preset_default.m_guid = columns_ui::panels::guid_horizontal_splitter;
				stream_writer_memblock_ref conf(preset_default.m_val, true);
				splitter->get_config(&conf, abort_callback_impl());

				p_out.add_item(preset_default);

				{
					t_size index = splitter_bottom->add_panel(&item_item_details);
					splitter_bottom->set_config_item_t(index, uie::splitter_window::bool_show_caption, bool(false), abort_callback_dummy());
					index = splitter_bottom->add_panel(&item_artwork);
					splitter_bottom->set_config_item_t(index, uie::splitter_window::bool_show_caption, bool(false), abort_callback_dummy());
					splitter_bottom->set_config_item_t(index, uie::splitter_window::uint32_size, t_size(125), abort_callback_dummy());
					splitter_bottom->set_config_item_t(index, uie::splitter_window::bool_locked, bool(true), abort_callback_dummy());

					splitter_bottom->get_config(&conf4, abort_callback_impl());
					item_bottom_splitter.set_panel_config(&stream_reader_memblock_ref(conf4.m_data.get_ptr(), conf4.m_data.get_size()), conf4.m_data.get_size());
					index = splitter3->add_panel(&item_bottom_splitter);
					splitter3->set_config_item_t(index, uie::splitter_window::bool_show_caption, bool(false), abort_callback_dummy());
					splitter3->set_config_item_t(index, uie::splitter_window::bool_locked, bool(true), abort_callback_dummy());
					splitter3->set_config_item_t(index, uie::splitter_window::uint32_size, t_size(125), abort_callback_dummy());
				}

				conf2.m_data.set_size(0);
				splitter3->get_config(&conf2, abort_callback_impl());
				item3.set_panel_config(&stream_reader_memblock_ref(conf2.m_data.get_ptr(), conf2.m_data.get_size()), conf2.m_data.get_size());

				splitter->replace_panel(index_splitter2, &item3);
				splitter->set_config_item_t(index_splitter2, uie::splitter_window::bool_show_caption, false, abort_callback_dummy());

				preset_default.m_name = "NG Playlist + Playlist Tabs + Filters + Item Details + Artwork";
				preset_default.m_guid = columns_ui::panels::guid_horizontal_splitter;

				splitter->get_config(&stream_writer_memblock_ref(preset_default.m_val, true), abort_callback_impl());


				t_size preset_tabs_all = p_out.add_item(preset_default);


				splitter3->remove_panel(0);
				conf2.m_data.set_size(0);
				splitter3->get_config(&conf2, abort_callback_impl());
				item3.set_panel_config(&stream_reader_memblock_ref(conf2.m_data.get_ptr(), conf2.m_data.get_size()), conf2.m_data.get_size());

				splitter->replace_panel(index_splitter2, &item3);
				splitter->set_config_item_t(index_splitter2, uie::splitter_window::bool_show_caption, false, abort_callback_dummy());

				preset_default.m_name = "NG Playlist + Playlist Tabs + Item Details + Artwork";
				preset_default.m_guid = columns_ui::panels::guid_horizontal_splitter;

				splitter->get_config(&stream_writer_memblock_ref(preset_default.m_val, true), abort_callback_impl());


				p_out.insert_item(preset_default, preset_tabs_all);
			}
		}
	}
}
Esempio n. 15
0
	void g_scan_drives (DWORD mask)
	{
	//pfc::hires_timer timer;
	//timer.start();
	//profiler(scandrives);
#if 0
		{
			TCHAR volume[128], mount[512];
			memset(volume, 0, sizeof(volume));
			HANDLE vol = FindFirstVolume(volume, tabsize(volume)-1);
			if (vol != INVALID_HANDLE_VALUE)
			{
				do
				{
					console::formatter() << "Volume: " << pfc::stringcvt::string_utf8_from_wide(volume, 128);
					memset(mount, 0, sizeof(mount));
					HANDLE hmount = FindFirstVolumeMountPoint(volume, mount, tabsize(mount)-1);
					if (hmount != INVALID_HANDLE_VALUE)
					{
						do
						{
							console::formatter() << "mountpoint: " << pfc::stringcvt::string_utf8_from_wide(mount, tabsize(mount));
							memset(mount, 0, sizeof(mount));
						}
						while (FindNextVolumeMountPoint(hmount, mount, tabsize(mount)-1) || GetLastError() != ERROR_NO_MORE_FILES);
						FindVolumeMountPointClose(hmount);

					}
					memset(volume, 0, sizeof(volume));
				}
				while (FindNextVolume(vol, volume, tabsize(volume)-1) || GetLastError() != ERROR_NO_MORE_FILES);
				FindVolumeClose(vol);
			}
		}
#endif
		if (mask)
		{
			t_volumes volumes;
			build_volumes_v2(volumes);

			t_size i =0;
			for (i=0; i<32; i++)
			{
				if (mask & 1<<i) 
				{
					pfc::string8 drive; drive.add_byte('A'+i);
					pfc::array_t<WCHAR> path, itunesdb_path;
					path.append_single('A'+i);
					path.append_fromptr(L":\\", 3);
					{
						WCHAR volumename[129];
						memset(volumename, 0, sizeof(volumename));
						if (GetDriveType(path.get_ptr()) == DRIVE_REMOVABLE && GetVolumeNameForVolumeMountPoint(path.get_ptr(), volumename, 128))
						{
							t_size indexvol;
							//if (volumes.find(volumename, 128, indexvol))
							{
								//FIXME WTF
								if (volumes.find(volumename, 128, indexvol) /*&& g_check_devid_is_ipod(volumes[indexvol].disk_device_id)*/)
								{
									ipod_device_ptr_t temp = new ipod_device_t('A' + i, volumes[indexvol].model, volumes[indexvol].shuffle, volumes[indexvol].disk_device_id.get_ptr(), volumes[indexvol].volume_name.get_ptr(), volumes[indexvol].driver_symbolic_path.get_ptr(), volumes[indexvol].instance, device_properties_t());

									pfc::string8 pl;
									try {
										g_get_device_xml(temp, pl);
#if 0//_DEBUG
										{
											file::ptr f;
											abort_callback_dummy noabort;
											filesystem::g_open_read(f, "i:\\nano6g.plist", noabort);
											pfc::array_staticsize_t<char> d(pfc::downcast_guarded<t_uint32>(f->get_size_ex(noabort)));
											f->read(d.get_ptr(), d.get_size(), noabort);
											pl.set_string(d.get_ptr(), d.get_size());
										}
#endif
										g_get_artwork_info(pl, temp->m_device_properties);
									} 
									catch (const pfc::exception & ex) 
									{
										console::formatter() << "iPod manager: Failed to get iPod checkpoint data - " << ex.what() << ". Artwork functionality will be unavailable.";
										temp->m_device_properties.m_artwork_formats.remove_all();
									};
									//console::formatter() << "New iPod detected. Drive: " << drive << " Device Instance ID: " << pfc::stringcvt::string_utf8_from_wide(volumes[indexvol].disk_device_id);
									if (m_abort)
										g_drive_manager.add_drive(temp, *m_abort);
									else
										g_drive_manager.add_drive(temp, abort_callback_dummy());
								}
								//else
								//	console::formatter() << "New drive detected. Drive: " << drive << " Device Instance ID: " << pfc::stringcvt::string_utf8_from_wide(volumes[indexvol].disk_device_id);// << " Volume ID: " << pfc::stringcvt::string_utf8_from_wide(volumes[indexvol].volume_name);
							}
						}
						//else
						//	console::formatter() << "Drive is not expected type or GetVolumeNameForVolumeMountPoint failed. Drive: " << drive;
					}
				}

			}
		}
		//console::formatter() << "old:" << timer.query();
	}