mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-03 10:02:14 +02:00
get friend codes
This commit is contained in:
parent
c5a9a909a9
commit
c2a0dabfa3
@ -11,6 +11,14 @@
|
|||||||
#include "../services/acc.h"
|
#include "../services/acc.h"
|
||||||
#include "../sf/service.h"
|
#include "../sf/service.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FriendServiceType_User = 0, ///< Initializes friend:u
|
||||||
|
FriendServiceType_V = 1, ///< Initializes friend:v
|
||||||
|
FriendServiceType_M = 2, ///< Initializes friend:m
|
||||||
|
FriendServiceType_S = 3, ///< Initializes friend:s
|
||||||
|
FriendServiceType_Application = 4 ///< Initializes friend:a
|
||||||
|
} FriendServiceType;
|
||||||
|
|
||||||
/// InAppScreenName
|
/// InAppScreenName
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[0x40]; ///< UTF-8 string, NUL-terminated.
|
char name[0x40]; ///< UTF-8 string, NUL-terminated.
|
||||||
@ -32,6 +40,36 @@ typedef struct {
|
|||||||
u64 id; ///< Id.
|
u64 id; ///< Id.
|
||||||
} FriendsFriendInvitationGroupId;
|
} FriendsFriendInvitationGroupId;
|
||||||
|
|
||||||
|
/// FriendsUserSetting
|
||||||
|
typedef struct {
|
||||||
|
AccountUid uid; ///< User ID
|
||||||
|
u32 presence_permission; ///< Presence permission
|
||||||
|
u32 play_log_permission; ///< Play log permission
|
||||||
|
u64 friend_request_reception; ///< Unknown
|
||||||
|
char friend_code[0x20]; ///< Friend Code
|
||||||
|
u64 friend_code_next_issuable_time; ///< Unknown
|
||||||
|
char extra[0x7C8]; ///< Extra
|
||||||
|
} FriendUserSetting;
|
||||||
|
|
||||||
|
/// Initialize friends
|
||||||
|
Result friendsInitialize(FriendServiceType service_type);
|
||||||
|
|
||||||
|
/// Exit friends
|
||||||
|
void friendsExit(void);
|
||||||
|
|
||||||
|
/// Gets the Service object for the friends service session.
|
||||||
|
Service * friendsGetServiceSession(void);
|
||||||
|
|
||||||
|
/// Gets the Service object for the actual IFriendsService service session.
|
||||||
|
Service* friendsGetServiceSession_IFriendsService(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the \ref FriendUserSetting details
|
||||||
|
* @param[in] uid \ref User AccountUid.
|
||||||
|
* @param[out] user_setting \ref FriendUserSetting
|
||||||
|
*/
|
||||||
|
Result friendsGetUserSetting(AccountUid uid, FriendUserSetting * user_setting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets an Event which is signaled when data is available with \ref friendsTryPopFriendInvitationNotificationInfo.
|
* @brief Gets an Event which is signaled when data is available with \ref friendsTryPopFriendInvitationNotificationInfo.
|
||||||
* @note This is a wrapper for \ref appletGetFriendInvitationStorageChannelEvent, see that for the usage requirements.
|
* @note This is a wrapper for \ref appletGetFriendInvitationStorageChannelEvent, see that for the usage requirements.
|
||||||
@ -51,4 +89,3 @@ NX_INLINE Result friendsGetFriendInvitationNotificationEvent(Event *out_event) {
|
|||||||
* @param[out] out_size Size of the data which was written into the output buffer. Optional, can be NULL.
|
* @param[out] out_size Size of the data which was written into the output buffer. Optional, can be NULL.
|
||||||
*/
|
*/
|
||||||
Result friendsTryPopFriendInvitationNotificationInfo(AccountUid *uid, void* buffer, u64 size, u64 *out_size);
|
Result friendsTryPopFriendInvitationNotificationInfo(AccountUid *uid, void* buffer, u64 size, u64 *out_size);
|
||||||
|
|
||||||
|
@ -1,6 +1,65 @@
|
|||||||
#include "service_guard.h"
|
#include "service_guard.h"
|
||||||
#include "services/friends.h"
|
#include "services/friends.h"
|
||||||
|
|
||||||
|
static FriendServiceType g_friendsServiceType;
|
||||||
|
|
||||||
|
static Service g_friendSrv;
|
||||||
|
static Service g_friendsIFriendService;
|
||||||
|
|
||||||
|
NX_GENERATE_SERVICE_GUARD_PARAMS(friends, (FriendServiceType service_type), (service_type));
|
||||||
|
|
||||||
|
Result _friendsInitialize(FriendServiceType service_type) {
|
||||||
|
Result rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||||
|
|
||||||
|
g_friendsServiceType = service_type;
|
||||||
|
|
||||||
|
switch (g_friendsServiceType) {
|
||||||
|
case FriendServiceType_User:
|
||||||
|
rc = smGetService(&g_friendSrv, "friend:u");
|
||||||
|
break;
|
||||||
|
case FriendServiceType_Application:
|
||||||
|
rc = smGetService(&g_friendSrv, "friend:a");
|
||||||
|
break;
|
||||||
|
case FriendServiceType_M:
|
||||||
|
rc = smGetService(&g_friendSrv, "friend:m");
|
||||||
|
break;
|
||||||
|
case FriendServiceType_V:
|
||||||
|
rc = smGetService(&g_friendSrv, "friend:v");
|
||||||
|
break;
|
||||||
|
case FriendServiceType_S:
|
||||||
|
rc = smGetService(&g_friendSrv, "friend:s");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = serviceDispatch(&g_friendSrv, 0,
|
||||||
|
.out_num_objects = 1,
|
||||||
|
.out_objects = &g_friendsIFriendService,
|
||||||
|
);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _friendsCleanup(void) {
|
||||||
|
serviceClose(&g_friendsIFriendService);
|
||||||
|
serviceClose(&g_friendSrv);
|
||||||
|
}
|
||||||
|
|
||||||
|
Service* friendsGetServiceSession(void) {
|
||||||
|
return &g_friendSrv;
|
||||||
|
}
|
||||||
|
|
||||||
|
Service* friendsGetServiceSession_IFriendsService(void)
|
||||||
|
{
|
||||||
|
return &g_friendsIFriendService;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result friendsGetUserSetting(AccountUid uid, FriendUserSetting * user_setting) {
|
||||||
|
return serviceDispatchIn(&g_friendsIFriendService, 20800, uid,
|
||||||
|
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out | SfBufferAttr_FixedSize },
|
||||||
|
.buffers = { { user_setting, sizeof(FriendUserSetting) } }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Result friendsTryPopFriendInvitationNotificationInfo(AccountUid *uid, void* buffer, u64 size, u64 *out_size) {
|
Result friendsTryPopFriendInvitationNotificationInfo(AccountUid *uid, void* buffer, u64 size, u64 *out_size) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
AppletStorage storage;
|
AppletStorage storage;
|
||||||
@ -27,4 +86,3 @@ Result friendsTryPopFriendInvitationNotificationInfo(AccountUid *uid, void* buff
|
|||||||
appletStorageClose(&storage);
|
appletStorageClose(&storage);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user