How to retrieve Steamwork SDK's current version - c++

Is it possible to get steamworks SDK's current version through C++ from the Steamworks API?
If yes, how?
This is what I'm looking for

You can use
ISteamAppList * GetISteamAppList( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion );
...
pchVersion const char * The version string that identifies the version of the interface that you receive.
Retrieves the ISteamAppList interface associated with the specified user handle, only available on specially registered apps.

Related

librdkafka custom logger, function signature

I'm using the librdkafka c++ API and I would like to change the default behavior of the logger.
In the c API there is this function rd_kafka_conf_set_log_cb() to set the log callback. It takes a function with the signature:
void(*)(const rd_kafka_t *rk, int level, const char *fac, const char *buf)
However I can't figure out what const char *fac does in the function signature. I can see that strings such as "FAIL" or "BGQUEUE" are passed when using it, but I can't find any documentation on what they mean or how to use them.
What is the const char *fac used for, and are there docs on its use or a dictionary for their definitions?
The facility string is a semi-unique name for the context where the log is emitted. It is mainly there to help librdkafka maintainers identify the source of a log line, but can also be used for filtering purposes.
It was originally inspired by Cisco IOS like system logs which came in the form of:
FAC-LVL-SUBFAC: Message...
The librdkafka counterpart would be:
RDKAFKA-7-JOIN: Joining consumer group xyx
where JOIN is the librdkafka logging facility.

Enumerate Upgrade Codes of installed products?

I'd like to get list of all Upgrade codes of all installed products on Windows box. The question is: is there a dedicated MSI function to address this request?
There is MsiEnumProducts() that enumerates all installed products and MsiEnumRelatedProducts() to enumerate all products for the given Upgrade code. But I can't find a function to get all Upgrade codes in the system.
The workaround I can imagine is use MsiEnumProducts() to get list of all installed products, open each with MsiOpenProduct() function and read "UpgradeCode" property with MsiGetProductProperty(). But this should be very slow due to multiple MsiOpenProduct() calls.
I believe MsiEnumProducts loop with MsiOpenProduct and then MsiGetProductProperty is the correct official sequence. If you really need faster and are willing to bypass the API's you could read the registry directly at HKCR\Installer\UpgradeCodes. You'll have to reverse the Darwin Descriptors though. This isn't technically supported but the reality is these keys have been there for 16 years and MSFT has been doing ZERO development on The Windows Installer. Ok, maybe they updated the version number and removed ARM support in Windows 10 LOL.
FWIW, I like to use C# not C++ but the concept is the same. The following snippet ran on my developer machine in about 2 seconds.
using System;
using Microsoft.Deployment.WindowsInstaller;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
foreach (var productInstallation in ProductInstallation.AllProducts)
{
using(var database = new Database(productInstallation.LocalPackage, DatabaseOpenMode.ReadOnly))
{
Console.WriteLine(database.ExecutePropertyQuery("UpgradeCode"));
}
}
}
}
}
According to the DTF documentation, ProductInstallation.AllProducts uses MsiEnumProducts. The Database class constructor is using MsiOpenDatabase and ExecutePropertyQuery is a higher level call that basically abstracts doing a SELECT Value from Property WHERE Property = '%s'. So it'll be calling APIs to create, execute and fetch results from views. All these classes implement IDisposable to call the correct APIs to free resources also.
Ya... that's why I love managed code. :)

What's the standard approach for configuration in Qt console apps?

In .Net you typically have an app.config file and built in ways to access the configuration.
Is there an equivalent standard approach to configuration using Qt?
For example, lets say my application connects to an online server, I want the ability to store the connection details (user defined).
Is this a case of "roll your own", or is there a way to store and read these configurations using XML, or any other format with easy read/write methods provided by Qt?
Edit: To add some complication to the question. This is a Linux console app, so looking specifically for file based and transparent config please.
You could use QSettings for this. Please refer to the documentation for details:
http://qt-project.org/doc/qt-5.1/qtcore/qsettings.html
You could always use other formats as well like XML, Json, and so forth, but generically speaking, QSettings is the way, or if you are writing a KDE application, then probably KConfig.
These are the two important methods you need to be aware of when dealing with QSettings for reading and writing:
Reading
QVariant QSettings::value(const QString & key,
const QVariant & defaultValue = QVariant()) const
Writing
void QSettings::setValue(const QString & key, const QVariant & value)
Then, you can simply stick to the native format (or even ini on your Linux if you prefer):
QSettings::NativeFormat 0 Store the settings using the most
appropriate storage format for the platform. On Windows, this means
the system registry; on Mac OS X, this means the CFPreferences API; on
Unix, this means textual configuration files in INI format.
Here you can find an example for your convenience:
#include <QSettings>
int main()
{
....
QSettings settings("Foo", "Bar");
// settings.beginGroup("application");
QString string = settings.value("foo", "bar");
// settings.endGroup();
....
}
Note, the groups are optional, and it depends on your exact purpose. You can group settings that way to keep certain ones encapsulated.
This may also be important for you to know as per documentation:
On Unix systems, if the file format is NativeFormat, the following files are used by default:
$HOME/.config/MySoft/Star Runner.conf (Qt for Embedded Linux: $HOME/Settings/MySoft/Star Runner.conf)
$HOME/.config/MySoft.conf (Qt for Embedded Linux: $HOME/Settings/MySoft.conf)
/etc/xdg/MySoft/Star Runner.conf
/etc/xdg/MySoft.conf

Using C++ to access Documents folder on iOS

I'm wondering if there is a way to get a reference to the Documents folder on iOS using just C++ (i.e. WITHOUT using ANY code in Objective-C; this because it is a framework implemented only in C++ that can be add as a library in a iOS project).
Please, if it is possible, provide code in your answer.
With code below I able to access cache folder in my app. I think, documents folder in "/Library/Documents", or somewere else.
char *home = getenv("HOME");
char *subdir = "/Library/Caches/subdir";
home + subdir = full path
Next, with full path, you can do usual things to read/write in C++
Yes, you have access to the plain Unix APIs. See Apples iOS manpages here.
Get the path (using Cocoa APIs), then convert it to a C++ string compatible representation using and API such as: CFStringGetFileSystemRepresentation, CFURLGetFileSystemRepresentation, or -[NSString fileSystemRepresentation].
Something like:
// you may need to wrap this in an autorelease pool
NSArray * paths(NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES));
const char* const path([[paths objectAtIndex:0] fileSystemRepresentation]);
if (0 == fsrep) {
uh-oh
}
const std::string result(path);
Then you can simply put that in its own ObjC++ translation and return result from the function (which would be visible to the rest of your C++ sources).

WinRT and missing Web API models for Amazon API access

I was working with porting the sample from the link below to a Windows 8 Metro styled app
http://aws.amazon.com/code/Product-Advertising-API/2480
Looks like many features from the web model are removed (or moved) in WinRT:
HttpUtility.UrlEncode
HttpUtility.UrlDecode
HMAC / HMACSHA256
to name a few. Are there alternatives to these on WInRT? I looked online and there's very little insight.
Theres source code for URLDecode here, and looks like Uri.EscapeDataString can be used for Encode.
http://www.koders.com/csharp/fid1A50096D8FA38302680B0EEDAC5B1CE1AEA855D0.aspx?s=%22Lawrence+Pit%22
copy the source code over, change the GetChars function to this
static char [] GetChars (MemoryStream b, Encoding e)
{
return e.GetChars (b.ToArray(), 0, (int) b.Length);
}
I had to use the code snippet from here to properly hash encrypt the string
http://channel9.msdn.com/Forums/TechOff/Porting-to-WinRT/4df7586e1ef5400682eda00f0143b610
Use methods from the WebUtility class instead:
System.Net.WebUtility.UrlEncode(string);
System.Net.WebUtility.UrlDecode(string);