// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package codeu.chat.client.core;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.UUID;

import codeu.chat.common.BasicController;
import codeu.chat.common.BasicView;
import codeu.chat.common.ConversationHeader;
import codeu.chat.common.User;
import codeu.chat.util.Uuid;

public final class UserContext {

  public final User user;
  private final BasicView view;
  private final BasicController controller;

  public UserContext(User user, BasicView view, BasicController controller) {
    this.user = user;
    this.view = view;
    this.controller = controller;
  }

  public ConversationContext start(String name) {
    final ConversationHeader conversation = controller.newConversation(name, user.id);
    return conversation == null ?
        null :
        new ConversationContext(user, conversation, view, controller);
  }

  public Iterable<ConversationContext> conversations() {

    // Use all the ids to get all the conversations and convert them to
    // Conversation Contexts.
    final Collection<ConversationContext> all = new ArrayList<>();
    for (final ConversationHeader conversation : view.getConversations()) {
      all.add(new ConversationContext(user, conversation, view, controller));
    }

    return all;
  }
  

  // USERstatusUpdate()
  public HashMap<Uuid, ArrayList<ArrayList<String>>> USERstatusUpdate(){ 
	  HashMap<Uuid, ArrayList<ArrayList<String>>> userUpdates = this.user.USERstatusUpdate(this.conversations()); 
	  return userUpdates; 
  }
}

@@ -2140,10 +2140,219 @@
 s; %0A  %7D%0A
+  %0A  // CONVOstatusUpdate() %0A  public HashMap%3CString, Integer%3E CONVOstatusUpdate()%7B %0A%09  HashMap%3CString, Integer%3E convoUpdates = this.user.CONVOstatusUpdate(this.conversations());%0A%09  return convoUpdates; %0A  %7D%0A%0A
 %7D%0A

Update UserContext.java