Package net.pterodactylus.sone.data

Examples of net.pterodactylus.sone.data.Sone


   * {@inheritDoc}
   */
  @Override
  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    Sone currentSone = getCurrentSone(request.getToadletContext(), false);
    SoneRescuer soneRescuer = webInterface.getCore().getSoneRescuer(currentSone);
    if (request.getMethod() == Method.POST) {
      if ("true".equals(request.getHttpRequest().getPartAsStringFailsafe("fetch", 4))) {
        long edition = Numbers.safeParseLong(request.getHttpRequest().getPartAsStringFailsafe("edition", 8), -1L);
        if (edition > -1) {
View Full Code Here


    super.processTemplate(request, templateContext);
    if (request.getMethod() == Method.POST) {
      String type = request.getHttpRequest().getPartAsStringFailsafe("type", 16);
      String id = request.getHttpRequest().getPartAsStringFailsafe(type, 36);
      String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
      Sone currentSone = getCurrentSone(request.getToadletContext());
      if ("post".equals(type)) {
        currentSone.removeLikedPostId(id);
      } else if ("reply".equals(type)) {
        currentSone.removeLikedReplyId(id);
      }
      throw new RedirectException(returnPage);
    }
  }
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    Sone currentSone = getCurrentSone(request.getToadletContext());
    Profile profile = currentSone.getProfile();

    /* get parameters from request. */
    String fieldId = request.getHttpRequest().getParam("field");
    Field field = profile.getFieldById(fieldId);
    if (field == null) {
      throw new RedirectException("invalid.html");
    }

    /* process POST request. */
    if (request.getMethod() == Method.POST) {
      if (request.getHttpRequest().getPartAsStringFailsafe("confirm", 4).equals("true")) {
        fieldId = request.getHttpRequest().getParam("field");
        field = profile.getFieldById(fieldId);
        if (field == null) {
          throw new RedirectException("invalid.html");
        }
        profile.removeField(field);
        currentSone.setProfile(profile);
      }
      throw new RedirectException("editProfile.html#profile-fields");
    }

    /* set current values in template. */
 
View Full Code Here

   */
  @Override
  public Object get(TemplateContext templateContext, Object object, String member) {
    Profile profile = (Profile) object;
    if ("avatar".equals(member)) {
      Sone currentSone = (Sone) templateContext.get("currentSone");
      if (currentSone == null) {
        /* not logged in? don’t show custom avatars, then. */
        return null;
      }
      String avatarId = profile.getAvatar();
      if (avatarId == null) {
        return null;
      }
      if (core.getImage(avatarId, false) == null) {
        /* avatar ID but no matching image? show nothing. */
        return null;
      }
      Sone remoteSone = profile.getSone();
      if (remoteSone.isLocal()) {
        /* always show your own avatars. */
        return avatarId;
      }
      ShowCustomAvatars showCustomAvatars = currentSone.getOptions().<ShowCustomAvatars> getEnumOption("ShowCustomAvatars").get();
      if (showCustomAvatars == ShowCustomAvatars.NEVER) {
        return null;
      }
      if (showCustomAvatars == ShowCustomAvatars.ALWAYS) {
        return avatarId;
      }
      if (showCustomAvatars == ShowCustomAvatars.FOLLOWED) {
        return currentSone.hasFriend(remoteSone.getId()) ? avatarId : null;
      }
      Trust trust = remoteSone.getIdentity().getTrust((OwnIdentity) currentSone.getIdentity());
      if (trust == null) {
        return null;
      }
      if ((showCustomAvatars == ShowCustomAvatars.MANUALLY_TRUSTED) && (trust.getExplicit() != null) && (trust.getExplicit() > 0)) {
        return avatarId;
View Full Code Here

      }
      if (fetching) {
        core.lockSone(sone);
        FreenetURI soneUri = sone.getRequestUri().setKeyType("SSK").setDocName("Sone-" + currentEdition).setMetaString(new String[] { "sone.xml" });
        System.out.println("URI: " + soneUri);
        Sone fetchedSone = soneDownloader.fetchSone(sone, soneUri, true);
        System.out.println("Sone: " + fetchedSone);
        lastFetchSuccessful = (fetchedSone != null);
        if (lastFetchSuccessful) {
          core.updateSone(fetchedSone, true);
        }
View Full Code Here

    if ("replies".equals(member)) {
      return Collections2.filter(core.getReplies(post.getId()), Reply.FUTURE_REPLY_FILTER);
    } else if (member.equals("likes")) {
      return core.getLikes(post);
    } else if (member.equals("liked")) {
      Sone currentSone = (Sone) templateContext.get("currentSone");
      return (currentSone != null) && (currentSone.isLikedPostId(post.getId()));
    } else if (member.equals("new")) {
      return !post.isKnown();
    } else if (member.equals("bookmarked")) {
      return core.isBookmarked(post);
    } else if (member.equals("loaded")) {
View Full Code Here

   */
  @Override
  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
    Sone sone = webInterface.getCore().getLocalSone(soneId, false);
    if (sone != null) {
      webInterface.getCore().unlockSone(sone);
    }
    String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
    throw new RedirectException(returnPage);
View Full Code Here

  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    if (request.getMethod() == Method.POST) {
      String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
      String identity = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
      Sone currentSone = getCurrentSone(request.getToadletContext());
      Optional<Sone> sone = webInterface.getCore().getSone(identity);
      if (sone.isPresent()) {
        webInterface.getCore().distrustSone(currentSone, sone.get());
      }
      throw new RedirectException(returnPage);
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public Object get(TemplateContext templateContext, Object object, String member) {
    Sone sone = (Sone) object;
    if (member.equals("niceName")) {
      return getNiceName(sone);
    } else if (member.equals("friend")) {
      Sone currentSone = (Sone) templateContext.get("currentSone");
      return (currentSone != null) && currentSone.hasFriend(sone.getId());
    } else if (member.equals("current")) {
      Sone currentSone = (Sone) templateContext.get("currentSone");
      return (currentSone != null) && currentSone.equals(sone);
    } else if (member.equals("modified")) {
      return core.isModifiedSone(sone);
    } else if (member.equals("status")) {
      return sone.getStatus();
    } else if (member.equals("unknown")) {
      return sone.getStatus() == SoneStatus.unknown;
    } else if (member.equals("idle")) {
      return sone.getStatus() == SoneStatus.idle;
    } else if (member.equals("inserting")) {
      return sone.getStatus() == SoneStatus.inserting;
    } else if (member.equals("downloading")) {
      return sone.getStatus() == SoneStatus.downloading;
    } else if (member.equals("new")) {
      return !sone.isKnown();
    } else if (member.equals("locked")) {
      return core.isLocked(sone);
    } else if (member.equals("lastUpdatedText")) {
      return GetTimesAjaxPage.getTime((WebInterface) templateContext.get("webInterface"), sone.getTime());
    } else if (member.equals("trust")) {
      Sone currentSone = (Sone) templateContext.get("currentSone");
      if (currentSone == null) {
        return null;
      }
      Trust trust = sone.getIdentity().getTrust((OwnIdentity) currentSone.getIdentity());
      logger.log(Level.FINEST, String.format("Trust for %s by %s: %s", sone, currentSone, trust));
      if (trust == null) {
        return new Trust(null, null, null);
      }
      return trust;
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    final Sone currentSone = getCurrentSone(request.getToadletContext());
    Collection<Post> allPosts = new ArrayList<Post>();
    allPosts.addAll(currentSone.getPosts());
    for (String friendSoneId : currentSone.getFriends()) {
      Optional<Sone> friendSone = webInterface.getCore().getSone(friendSoneId);
      if (!friendSone.isPresent()) {
        continue;
      }
      allPosts.addAll(friendSone.get().getPosts());
    }
    for (Sone sone : webInterface.getCore().getSones()) {
      for (Post post : sone.getPosts()) {
        if (currentSone.equals(post.getRecipient().orNull()) && !allPosts.contains(post)) {
          allPosts.add(post);
        }
      }
    }
    allPosts = Collections2.filter(allPosts, new Predicate<Post>() {
View Full Code Here

TOP

Related Classes of net.pterodactylus.sone.data.Sone

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.