mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-27 12:32:14 +02:00
Added support for friendsLa. Added friends.h.
This commit is contained in:
parent
3d682b6748
commit
fa25df27d0
@ -93,6 +93,7 @@ extern "C" {
|
||||
#include "switch/services/pctl.h"
|
||||
#include "switch/services/pdm.h"
|
||||
#include "switch/services/grc.h"
|
||||
#include "switch/services/friends.h"
|
||||
|
||||
#include "switch/display/binder.h"
|
||||
#include "switch/display/parcel.h"
|
||||
@ -113,6 +114,7 @@ extern "C" {
|
||||
|
||||
#include "switch/applets/libapplet.h"
|
||||
#include "switch/applets/album_la.h"
|
||||
#include "switch/applets/friends_la.h"
|
||||
#include "switch/applets/pctlauth.h"
|
||||
#include "switch/applets/error.h"
|
||||
#include "switch/applets/swkbd.h"
|
||||
|
93
nx/include/switch/applets/friends_la.h
Normal file
93
nx/include/switch/applets/friends_la.h
Normal file
@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @file friends_la.h
|
||||
* @brief Wrapper for using the MyPage (friends) LibraryApplet.
|
||||
* @author yellows8
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "../services/friends.h"
|
||||
|
||||
/// Arg type values used with \ref FriendsLaArg.
|
||||
typedef enum {
|
||||
FriendsLaArgType_ShowFriendList = 0, ///< ShowFriendList. Launches the applet with the "Friend List" menu initially selected.
|
||||
FriendsLaArgType_ShowUserDetailInfo = 1, ///< ShowUserDetailInfo
|
||||
FriendsLaArgType_StartSendingFriendRequest = 2, ///< StartSendingFriendRequest
|
||||
FriendsLaArgType_ShowMethodsOfSendingFriendRequest = 3, ///< ShowMethodsOfSendingFriendRequest. Launches the applet with the "Add Friend" menu initially selected.
|
||||
FriendsLaArgType_StartFacedFriendRequest = 4, ///< StartFacedFriendRequest. Launches the applet where the "Search for Local Users" menu is initially shown. Returning from this menu will exit the applet.
|
||||
FriendsLaArgType_ShowReceivedFriendRequestList = 5, ///< ShowReceivedFriendRequestList. Launches the applet where the "Received Friend Requests" menu is initially shown. Returning from this menu will exit the applet.
|
||||
FriendsLaArgType_ShowBlockedUserList = 6, ///< ShowBlockedUserList. Launches the applet where the "Blocked-User List" menu is initially shown. Returning from this menu will exit the applet.
|
||||
FriendsLaArgType_ShowMyProfile = 7, ///< ShowMyProfile. Launches the applet with the "Profile" menu initially selected. ShowMyProfileForHomeMenu is identical to this except for playStartupSound=true.
|
||||
} FriendsLaArgType;
|
||||
|
||||
/// Arg struct pushed for the applet input storage.
|
||||
/// The fields following the userID are only set for ::FriendsLaArgType_ShowUserDetailInfo/::FriendsLaArgType_StartSendingFriendRequest, for everything else these are cleared.
|
||||
typedef struct {
|
||||
u32 type; ///< \ref FriendsLaArgType
|
||||
u32 pad; ///< Padding.
|
||||
union { u128 userID; } PACKED; ///< Account userID.
|
||||
u64 networkServiceAccountId; ///< NetworkServiceAccountId for the other account.
|
||||
FriendsInAppScreenName first_inAppScreenName; ///< First InAppScreenName.
|
||||
FriendsInAppScreenName second_inAppScreenName; ///< Second InAppScreenName.
|
||||
} FriendsLaArg;
|
||||
|
||||
/**
|
||||
* @brief Launches the applet with ::FriendsLaArgType_ShowFriendList, the specified input, and playStartupSound=false.
|
||||
* @param[in] userID Account userID.
|
||||
*/
|
||||
Result friendsLaShowFriendList(u128 userID);
|
||||
|
||||
/**
|
||||
* @brief Launches the applet with ::FriendsLaArgType_ShowUserDetailInfo, the specified input, and playStartupSound=false.
|
||||
* @param[in] userID Account userID.
|
||||
* @param[in] networkServiceAccountId NetworkServiceAccountId for the user to show UserDetailInfo for.
|
||||
* @param[in] first_inAppScreenName First \ref FriendsInAppScreenName.
|
||||
* @param[in] second_inAppScreenName Second \ref FriendsInAppScreenName.
|
||||
*/
|
||||
Result friendsLaShowUserDetailInfo(u128 userID, u64 networkServiceAccountId, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName);
|
||||
|
||||
/**
|
||||
* @brief Launches the applet with ::FriendsLaArgType_StartSendingFriendRequest, the specified input, and playStartupSound=false. On success, this will load the output Result from the output storage.
|
||||
* @param[in] userID Account userID.
|
||||
* @param[in] networkServiceAccountId NetworkServiceAccountId to send the friend request to.
|
||||
* @param[in] first_inAppScreenName First \ref FriendsInAppScreenName.
|
||||
* @param[in] second_inAppScreenName Second \ref FriendsInAppScreenName.
|
||||
*/
|
||||
Result friendsLaStartSendingFriendRequest(u128 userID, u64 networkServiceAccountId, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName);
|
||||
|
||||
/**
|
||||
* @brief Launches the applet with ::FriendsLaArgType_ShowMethodsOfSendingFriendRequest, the specified input, and playStartupSound=false.
|
||||
* @param[in] userID Account userID.
|
||||
*/
|
||||
Result friendsLaShowMethodsOfSendingFriendRequest(u128 userID);
|
||||
|
||||
/**
|
||||
* @brief Launches the applet with ::FriendsLaArgType_StartFacedFriendRequest, the specified input, and playStartupSound=false.
|
||||
* @param[in] userID Account userID.
|
||||
*/
|
||||
Result friendsLaStartFacedFriendRequest(u128 userID);
|
||||
|
||||
/**
|
||||
* @brief Launches the applet with ::FriendsLaArgType_ShowReceivedFriendRequestList, the specified input, and playStartupSound=false.
|
||||
* @param[in] userID Account userID.
|
||||
*/
|
||||
Result friendsLaShowReceivedFriendRequestList(u128 userID);
|
||||
|
||||
/**
|
||||
* @brief Launches the applet with ::FriendsLaArgType_ShowBlockedUserList, the specified input, and playStartupSound=false.
|
||||
* @param[in] userID Account userID.
|
||||
*/
|
||||
Result friendsLaShowBlockedUserList(u128 userID);
|
||||
|
||||
/**
|
||||
* @brief Launches the applet with ::FriendsLaArgType_ShowMyProfile, the specified input, and playStartupSound=false.
|
||||
* @param[in] userID Account userID.
|
||||
*/
|
||||
Result friendsLaShowMyProfile(u128 userID);
|
||||
|
||||
/**
|
||||
* @brief Same as \ref friendsLaShowMyProfile except with playStartupSound=true.
|
||||
* @param[in] userID Account userID.
|
||||
*/
|
||||
Result friendsLaShowMyProfileForHomeMenu(u128 userID);
|
||||
|
16
nx/include/switch/services/friends.h
Normal file
16
nx/include/switch/services/friends.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @file friend.h
|
||||
* @brief Friends (friend:*) service IPC header.
|
||||
* @author yellows8
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "../services/sm.h"
|
||||
|
||||
/// InAppScreenName
|
||||
typedef struct {
|
||||
char name[0x40]; ///< UTF-8 string, NUL-terminated.
|
||||
u64 languageCode; ///< LanguageCode, see set.h.
|
||||
} FriendsInAppScreenName;
|
||||
|
75
nx/source/applets/friends_la.c
Normal file
75
nx/source/applets/friends_la.c
Normal file
@ -0,0 +1,75 @@
|
||||
#include <string.h>
|
||||
#include "types.h"
|
||||
#include "result.h"
|
||||
#include "services/applet.h"
|
||||
#include "applets/libapplet.h"
|
||||
#include "applets/friends_la.h"
|
||||
|
||||
static Result _friendsLaShow(const FriendsLaArg *arg, bool playStartupSound) {
|
||||
Result rc=0;
|
||||
Result rc2=0;
|
||||
size_t readsize=0;
|
||||
LibAppletArgs commonargs;
|
||||
|
||||
libappletArgsCreate(&commonargs, 0x1);
|
||||
libappletArgsSetPlayStartupSound(&commonargs, playStartupSound);
|
||||
|
||||
if (arg->type != FriendsLaArgType_StartSendingFriendRequest)
|
||||
rc = libappletLaunch(AppletId_myPage, &commonargs, arg, sizeof(*arg), NULL, 0, NULL);
|
||||
else {
|
||||
rc = libappletLaunch(AppletId_myPage, &commonargs, arg, sizeof(*arg), &rc2, sizeof(rc2), &readsize);
|
||||
if (R_SUCCEEDED(rc) && readsize!=sizeof(rc2)) rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||
if (R_SUCCEEDED(rc)) rc = rc2;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _friendsLaShowSimple(FriendsLaArgType type, u128 userID, bool playStartupSound) {
|
||||
FriendsLaArg arg = {.type = type, .userID = userID};
|
||||
|
||||
return _friendsLaShow(&arg, playStartupSound);
|
||||
}
|
||||
|
||||
static Result _friendsLaShowAll(FriendsLaArgType type, u128 userID, u64 networkServiceAccountId, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName, bool playStartupSound) {
|
||||
FriendsLaArg arg = {.type = type, .userID = userID, .networkServiceAccountId = networkServiceAccountId, .first_inAppScreenName = *first_inAppScreenName, .second_inAppScreenName = *second_inAppScreenName};
|
||||
|
||||
return _friendsLaShow(&arg, playStartupSound);
|
||||
}
|
||||
|
||||
Result friendsLaShowFriendList(u128 userID) {
|
||||
return _friendsLaShowSimple(FriendsLaArgType_ShowFriendList, userID, false);
|
||||
}
|
||||
|
||||
Result friendsLaShowUserDetailInfo(u128 userID, u64 networkServiceAccountId, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName) {
|
||||
return _friendsLaShowAll(FriendsLaArgType_ShowUserDetailInfo, userID, networkServiceAccountId, first_inAppScreenName, second_inAppScreenName, false);
|
||||
}
|
||||
|
||||
Result friendsLaStartSendingFriendRequest(u128 userID, u64 networkServiceAccountId, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName) {
|
||||
return _friendsLaShowAll(FriendsLaArgType_StartSendingFriendRequest, userID, networkServiceAccountId, first_inAppScreenName, second_inAppScreenName, false);
|
||||
}
|
||||
|
||||
Result friendsLaShowMethodsOfSendingFriendRequest(u128 userID) {
|
||||
return _friendsLaShowSimple(FriendsLaArgType_ShowMethodsOfSendingFriendRequest, userID, false);
|
||||
}
|
||||
|
||||
Result friendsLaStartFacedFriendRequest(u128 userID) {
|
||||
return _friendsLaShowSimple(FriendsLaArgType_StartFacedFriendRequest, userID, false);
|
||||
}
|
||||
|
||||
Result friendsLaShowReceivedFriendRequestList(u128 userID) {
|
||||
return _friendsLaShowSimple(FriendsLaArgType_ShowReceivedFriendRequestList, userID, false);
|
||||
}
|
||||
|
||||
Result friendsLaShowBlockedUserList(u128 userID) {
|
||||
return _friendsLaShowSimple(FriendsLaArgType_ShowBlockedUserList, userID, false);
|
||||
}
|
||||
|
||||
Result friendsLaShowMyProfile(u128 userID) {
|
||||
return _friendsLaShowSimple(FriendsLaArgType_ShowMyProfile, userID, false);
|
||||
}
|
||||
|
||||
Result friendsLaShowMyProfileForHomeMenu(u128 userID) {
|
||||
return _friendsLaShowSimple(FriendsLaArgType_ShowMyProfile, userID, true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user